Welcome to WebmasterWorld Guest from 22.214.171.124 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
web expression regular expressions using find and replace santapaws
wonder if anyone knows if its possible to use regular expressions on both the find and the replace element. In short if i want to find all occurrences of: £ [0-9] million where [0-9] is any number in that set and replace only the £ sign to something else, can it be done. I dont see how the replace element can be specified to only replace the £ with say a $ and leave the number part untouched.
You have to capture the number in the "find" part: ([0-9]+) with + to allow for inflation ;) and then call it $1 in the "replace" part. santapaws
tx but i cant get this to work. how exactly should the $1 be written, ($1)? well ive tried all combos but none work, i.e. [$1] , ([$1]), ([0-9]$1) etc. :( lucy24
No, no, it's just $1. Parentheses mean "hang on to this text". $1 (and $2, $3 and so on if you're being fancy) mean "now spit it out again". For example-- pulling something out of my own htaccess-- in
RedirectMatch 301 /paintings/blowups/(\w+)/(?:large)?(\w+)\.html$ /paintings/$1/$2.html
the first parenthesized bit goes into the $1 slot, and the second bit goes into the $2 slot, so
I do not actually have pages with these names.