
- You are not logged in. | Login
March 12, 2007 1:10 pm
- mastaweb99
- Member


Excluding symbols. Regulars
Hallo, everybody!
Regular expression '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-_.!~*\';\/?%^\\\\:@&={\|}+$#\(\),\[\][:alnum:]])+)/se' isn’t written by me but I need to correct it in order to select only those who have no #img at the end.
I’ve read that I need to add (?!#img) and everything will be all right but I didn’t manage it
The source code
$p_string = preg_replace( '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-_.!~*\';\/?%^\\\\:@&={\|}+$#\(\),\[\][:alnum:]])+)/se', "not img", $p_string);The code that doesn’t function
$p_string = preg_replace( '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-_.!~*\';\/?%^\\\\:@&={\|}+$#\(\),\[\][:alnum:]])+)(?!#img)/se', "not img", $p_string);Help me, please!
March 12, 2007 1:22 pm
- shadow122
- Member


Re: Excluding symbols. Regulars
isn’t written by me but I need to correct it
You’ll examine regular expressions too
I doubt that someone is going to examine your_others regular expression…
March 12, 2007 1:26 pm
- mastaweb99
- Member


Re: Excluding symbols. Regulars
Regular expression doesn’t matter – I can reduce it and nothing changes…
'/\.\d*(?!#img)/' – to eliminate only those of them that don’t have #img at the end
March 12, 2007 1:28 pm
- PilgrimFarAway
- Member


Re: Excluding symbols. Regulars
These long expressions
([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:d.........
first should be replaced with the simple ones [^...] i.e. you are to check presence of admissible characters first instead of checking all the symbols.
to eliminate only those of them that don’t have #img at the end
This task is solved perfectly by strrchr($str, '#img'). If its length != 4, you are to eliminate it.


