I have the thankless task of editing a ton of HTML files. I have a bunch of URLs that all have different IDs, but I want to point to the same place. So, I investigated regex searching in VS. Well, the regex was easy, and the search found all my strings. Replace, however, leaves the regex section behind. My search was s=c&vl=vlg&vi=\d*, and it would replace s=c&vl=vlg&vi= and leave my digits behind.
Some googling told me that VS has it's own Regex syntax ( although using standard syntax WAS matching my strings ), so I tried that. Still no dice, I get matches, but it won't replace the bit matched by regex. I am unsure what the point of that is.
So, I decided to try wildcards. s=c&vl=vlg&vi=#* works perfectly, it searches AND replaces. So, I showed it to friends I'd been asking for help with the regex. Some guy says 'but you always want there to be a number, * is zero or more'. I KNOW I was reading MSDN, so I grab the entry to prove him wrong. Here is the text from MSDN:
One or more characters * Matches zero or more characters. For example, new* matches any text that includes "new", such as newfile.txt.
So, is it one or more, or zero or more ? It's one or more. But, I had to test, because the documentation contradicts itself. How very helpful.
Tuesday, June 28, 2011
Subscribe to:
Posts (Atom)