Jump to content

Recommended Posts

I'm trying to grab all names (in: LNAME, FNAME, POSSIBLE INITIAL) in a bunch of text, I have this set of rules:

 

 

/[^OWNER NAME].*([^0-9+][A-Z]{1}[^0-9+][a-z]+[^0-9+]\, [A-Z]{1}[^0-9+][a-z]+[^0-9+])/'

 

What I'm trying to do is some names have "OWNER NAME" very recently in the last line or two before the name, and I -do not- want those. Only if that string isn't found in in the last line or two do I want it.

 

Example of a name I would -not- want to collect:

 

OWNER NAME (IF SAME, WRITE “SAMEâ€)                                                                         ADDRESS (STREET, CITY, STATE, ZIP CODE)             5
                        Wu, Isabella     
[code]

Example of returned strings matching current rules:

Array ( [1] => Okulich, Kathern, [2] => Broadus, Raymond, Avery )

[EDIT: the reasons I account for no numbers is because it was pulling back home addresses. also, the pattern above simply doesn't work.]

Link to comment
https://forums.phpfreaks.com/topic/248929-regex-how-to-ignore-a-literal-string/
Share on other sites

Well, I already stated that I did not understand your question as asked. The fact that no one else has responded probably means no one else understood it either. Why don't you try doing what I asked, give some examples of the input you wouold have and the expected output.

Your regex starts like /[^OWNER NAME]

 

This is not doing what you think it is! It's actually just checking for "a single character that is not in the set of characters O, W, N, E, R, <space>, A and M".

 

You probably want something like /^(?!OWNER NAME) which makes sure that the line doesn't start with "OWNER NAME". For help on the (?!...) search on "regex lookaround".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.