using a regular expression replace string in VS 2003
-
Hi, According to the documentation, in the "find & replace" dialog I should be able to use a regular expression as a replacement string if the "Use:" checkbox is enabled and "Regular Expressions" is selected. I'm trying to do the following: replace the first string with the second string: mName kName mValue kValue mDescription kDescription I'm using the following regular expressions in the find and replace fields: find what: "^m.+" replace with: "^k.+" Did I miss something? Thanks Hua-Ying -- modified at 15:20 Thursday 29th September, 2005
-
Hi, According to the documentation, in the "find & replace" dialog I should be able to use a regular expression as a replacement string if the "Use:" checkbox is enabled and "Regular Expressions" is selected. I'm trying to do the following: replace the first string with the second string: mName kName mValue kValue mDescription kDescription I'm using the following regular expressions in the find and replace fields: find what: "^m.+" replace with: "^k.+" Did I miss something? Thanks Hua-Ying -- modified at 15:20 Thursday 29th September, 2005
Yeah - replace expressions are *NOT* regular expressions. They're effectively format strings. You want something like: find: {[^:a]}m{:i} replace: \1k\2 The find expression looks for a non-alpanumeric character before 'm' and hten an identifier pattern after the m and captures the non-alphanumeric character (in \1) and the identifier (in \2). The replace pattern outputs the concatenation of the first capture, k and the second capture. Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
-
Yeah - replace expressions are *NOT* regular expressions. They're effectively format strings. You want something like: find: {[^:a]}m{:i} replace: \1k\2 The find expression looks for a non-alpanumeric character before 'm' and hten an identifier pattern after the m and captures the non-alphanumeric character (in \1) and the identifier (in \2). The replace pattern outputs the concatenation of the first capture, k and the second capture. Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'