Closed Thread Icon

Topic awaiting preservation: regex to match numbers (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26393" title="Pages that link to Topic awaiting preservation: regex to match numbers (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: regex to match numbers <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-06-2005 06:22

Greets!
I basically need to strip lines like this:

<A HREF="javascript:Show_Image('/mipsor/images/08656931.jpg')"><strong>Click HERE for Photograph</strong></a>

out of a variable using preg_replace. The name of the jpg is different each time. How can I match this field?

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-06-2005 07:59
code:
(?Ui)([/mipsor/images/])([0-9]{1,8})([\.jpg])



That should, if i rmember my regex correctly, match the literal string '/mipsor/images/', then any string of numbers from 0 to 9, between 1 and 8 characters in length, inclusive, then the literal string '.jpg'... does that help?


Justice 4 Pat Richard

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-06-2005 15:57

That should do it. Thanks!

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 08-06-2005 19:07
quote:

code:
(?Ui)([/mipsor/images/])([0-9]{1,8})([\.jpg])

e]





I think you want that to be:

code:
(?Ui)(/mipsor/images/)([0-9]{1,8})(\.jpg)



.



-- not necessarily stoned... just beautiful.

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-07-2005 00:20

aah, yes... sorry. I was treating the two literal strings as sets of characters.


Justice 4 Pat Richard

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 08-07-2005 22:47

Also if you're just interested in the filename, you don't need the grouping parentheses around the path and extension.

code:
(?Ui)/mipsor/images/([0-9]{1,8})\.jpg


should suffice.

What is the (?Ui) part of this line? I just copied it because you put it there Skaarjj. I assume it's a PHP thing, I don't understand

.



-- not necessarily stoned... just beautiful.

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-08-2005 03:30

It's a settings string, makes it case insensitive and flips the greediness


Justice 4 Pat Richard

« BackwardsOnwards »

Show Forum Drop Down Menu