The resulting regular expression would be very complicated specially if you have a lot exceptions like 'foo-bar.
The resulting regular expression would be very complicated specially if you have a lot exceptions like 'foo-bar'. You should use a conditional subpattern with a lookbehind as condition and a lookahead as its yes-pattern: $res = preg_split('/(?(? string(5) "aasdf" 1=> string(6) "fafsdf" 2=> string(7) "foo-bar" 3=> string(4) "asdf" } Let me explain what is happening here. \- means Match any dash character.
But what we want is Match any dash character that is not part of foo-bar. Since we can't implement that in regex as it is we change it a little: Match any dash character that if preceded by foo is not followed by bar. To implement the if part we use a conditional subpattern, this is the syntax: (?(condition)yes-pattern|no-pattern) Our "condition" would be "preceded by foo" to check for that we use a lookbehind: (?Bar) And that becomes our "yes-pattern".
Our "no-pattern" should be \- or "any dash". The complete regex would be: (?(?Bar)|\-) UPDATE: to incorporate this into your current regex change this part at the end: |\ - |\ - |\- |\-|\ -/ to |\s?(?(?
I'm not sure how this particular example would incorporate into the original preg_split conditions. I'm attempting various ways on my server right now and I can't find one which produces the desired result. Thanks for the response.
– Tony Aug 6 at 16:17 @Tony see the update. – nobody Aug 6 at 16:30 @Tony BTW the way you are detecting whitespaces right now is very inefficient do it like this: /\s?(?:&|>|\/|\? |\:\:|\:|\-)\s?
/ – nobody Aug 6 at 17:48 Thanks for the help. It is much appreciated. Your 'foo-bar' code works perfect.
Now, the reason why I'm doing preg_split in this manner is because sometimes there is white space (one or two white spaces) that are sometimes before and sometimes after the delimiters. And sometimes, there is no whitespace before or after the delimiter. Delimiters, totaling 10 thus far are: 1.
# 2. & 3. > 4.
> 5. & 6. , 7.
::, 8. / 9. :, 10.
- being a n00b with php, I'm not sure if your more efficient code would be compatible with my purposes, and even it it were, I'm not sure how to implment it all. – Tony Aug 6 at 22:31 @Tony those \s? At the beginning and the end of the pattern mean "one or zero spaces", it will match all the white space combinations you mentioned.
– nobody Aug 6 at 22:53.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.