Take anything, but absolutely not one phrase
Moderator: General Moderators
Take anything, but absolutely not one phrase
in a preg_match_all I have a (.*?), I want it to take all characters, however, I want it to absolutely stop no matter what at "Employer" is there something like [^"Employer"]*?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
I'm thinking about it, but I haven't found a good way yet. My reference book is at work....
However can you explain a little more about the problem. It seems like you could do something with strpos to check for "Employer" first.
Or if you know that Employer will always be present and you want to grab everything before it, just do "\(.*)?Employer(.*)?\" to match everything before and everything after, excluding the "Employer" text...
Do either of these ideas fit your needs?
However can you explain a little more about the problem. It seems like you could do something with strpos to check for "Employer" first.
Or if you know that Employer will always be present and you want to grab everything before it, just do "\(.*)?Employer(.*)?\" to match everything before and everything after, excluding the "Employer" text...
Do either of these ideas fit your needs?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You could mean this is more than one way. Do you mean you want EVERYTING up UNTIL the word "employer" or do you mean you want EVERYTING EXCEPT the word exployer. Two different regex (one's a replace and one's a match).

Code: Select all
//Up util
preg_match('/^(.*?)(?:Employer)?.*$/is', $string, $matches);
$extract = $matches[1];
//Everything except... bah, I'm not even gonna write it... str_replace() would even do it!what is the colon doing there d11?
that colon just before Employer...what does that do?
Code: Select all
(?:Employer)