- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the "Use: Regular Expressions" option in the Find/Replace window to help find strings.
However, when trying to use "negative lookbehind" to exclude certain words if they are preceded by a certain string (which is really helpful to prevent recursive find-replace when only adding/subtracting onto the start/end of a string (e.g. replacing "Test" with "ATest", and then the find/replace trying to replace the "Test" in "ATest" with "ATest" again, giving the erranous "AATest").
When I try "(?<!A)Test" (which means find every "Test" that isn't preceded by an "A"), I get the error "The given expression is invaid". However, this works fine in the online regex sandbox's (e.g. http://regex.powertoy.org/).
I was just wondering if anyone knew what version of Regex PSoC Creator uses?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you press F1 in the find dialog, you get the help. From there, the Regex help is linked showing all allowed constructs.
In short: negation is done via '~', not '!'
But I just tried replacing 'test' with 'atest', and it replaced all occurences only once (as would be expected). What use case doesn't work for you, then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works if you use "Replace All", however, if you just use "Replace", because of a bug with Find/Replace, it can go back over previous material before searching through the entire project (I documented that bug here: cladlab.com/programming/microcontrollers/psoc/psoc-creator).
I tried the '~' symbol, but it didn't work. Even the example they gave didn't work! (that "reality" one). And evidence to suggest that '!' is negate, not '~', comes from the fact that negaitve lookahead does work.
For example, "test(?!ing)" will match "test', "tester" and "atest", but not "testing" (as you would expect).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot reproduce the problem with the find/replace dialog. I start with 'find next', it select the first match. When I press 'replace', the replacement happens and the selection jumps immediately to the next match. Which version of Creator are you using?
Apart from that, just file a support case (it looks like the documentation does not really match the implementation...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you have to have multiple files (and be using find/replace in a larger-than-just-the-single-file scope) for the problem to occur. I am using PSoC Creator v2.2.
O.K., I'll file a support case