View Full Version : Regarding Regular Expressions

03-16-2003, 09:14 PM
I'm having trouble with a regular expression.

My pattern is:

And my sample text is just gohasghiohg [ img]enter8.gif[/ img] dsfsf

(I had to add spaces in to the img tags to prevent the vB code from grabbing them)

I'm trying to find any occurances of the img tags cuz then it will give me the position and the length. But i'm having trouble with the pattern.

I don't have much experience with regular expressions so does anyone have any ideas?

03-17-2003, 12:04 PM
At the moment, your pattern will only look for things like:

[ IMG]p.3[ /IMG]

I dont think that is what you are looking for...

You might want to try:


This will match anything with the format of:

[ IMG]BLA1_bla2.giF2[ /IMG]

\w: Matches any alphanumeric character, including the underscore (same as [A-Za-z0-9_]).
+: Matches 1 or more instances of preceding character.

If you want more info, go to http://www.4guysfromrolla.com/webtech/RegularExpressions.shtml

Hope I helped :cool:

03-17-2003, 07:22 PM
Quite helpful.

Looks promising, I'll give it a try when I get home.