Forum Moderators: coopster

Message Too Old, No Replies

Regex for a delete

         

ukgimp

10:43 am on Apr 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a caaching script that works nicely, it extracts the url and makes an .inc file. However is has a feature where it will make a more than one page

so generally the inc file is called

c=X.inc

where X is an integer. But sometimes it has

c=X&S=Y

where y is also an interger.

I could run the delete function twice but that seems like a waste of processing

So with just one:
$c = X

c=*.inc works a treat and with two:

$c = X
$s = Y

c=$c&s=*.inc

Is there a way of combining the two into one regex

Cheers

<added>

forget to say the bit that is getting me is the possibility of deleting both 3 and 33 for example when I only wanted 3 to be nuked
</added>

coopster

7:13 pm on Apr 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Can you show us a sample string and your current regex?

ergophobe

8:46 pm on Apr 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



and just to get you going

possibility of deleting both 3 and 33 for example when I only wanted 3 to be nuked

\d - matches one digit
\d+ - one or more digit
\d* - zero or more digits
[^\d]* - all text up to the digit
([^\d]*)(\d)(.*) - all text up to the digit in one group and the digit in the next group and everything else in the last group. So with var3comment, the replacement group '$1 = $2; # $3' yields "var = 3; #comment"

If you want to fiddle around, there is a great online regex tester at

[fileformat.info...]

ukgimp

8:05 am on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>Can you show us a sample string and your current regex?

My current regex is non existant, it was just meesing with my head so I run the functin twice.

Ergo' (sorry forgot how to spell your name :))

Thansk for the tips and the link. Will be checking tha out shortly.

Cheers