View Full Version : Quick Regex Question


cptsmidge
03-05-2012, 08:26 AM
Hey, sorry to bother everyone with another Regex question.

My book has weird question marks in place of hyphens (book?worm, land?locked), and I was trying to replace it, but I can't get the replace string to work.

Right now I'm using this as the search string, which seems to only select the question marks with characters on either side (not proper question marks):

\w\?\w

But no matter what I try in the "Replace" area, whatever I typed gets inserted into the code.

I tried variations of:

\1 \2

But no luck.

DiapDealer
03-05-2012, 08:40 AM
You have no capture groups in your search expression. So it doesn't know what to replace and what to keep.

(\w)\?(\w)

\1-\2
should then replace the "?" with the "-" and keep the two original word-characters preceding and following.

cptsmidge
03-05-2012, 10:26 AM
Oh thank you! Thanks for the quick response too. 1159 replacements made.

DiapDealer
03-05-2012, 12:14 PM
Oh thank you! Thanks for the quick response too. 1159 replacements made.
You're quite welcome. But I hope you stepped through several instances to make sure it was doing what you wanted before you hit "Replace All." :eek:

cptsmidge
03-05-2012, 12:21 PM
Absolutely. I did probably 3 complete html documents before I committed. It isn't perfect, but that's the fault of the inconsistency of the file, not the code.

huebi
03-05-2012, 01:12 PM
But I hope you stepped through several instances to make sure it was doing what you wanted before you hit "Replace All." :eek:

No risk, no fun.

Toxaris
03-06-2012, 04:20 AM
No risk, no fun.

:rofl: