What Version Of Regex Does PSoC Creator Find/Replace Use?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 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?

0 Likes
4 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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?

0 Likes
Anonymous
Not applicable

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).

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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...)

0 Likes
Anonymous
Not applicable

 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

0 Likes