What would be the use-case? For RegEx, you have a special character for linefeed(s) you can use. You can use RegEx for search/replace and ignore. Therefore, in the case you need a linefeed you should not use the from/to but the RegEx option. Line-feeds would need to be escaped which is error-prone. So unless its really needed and there is no work-around I would not want to to implement this. Keep in mind: You can ignore white-spaces which removes extensive CR-LF usage. This might also be of help.
But maybe you come up with a use-case first for me to understand...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But how does one specify CR or LF in regex replacement strings in WCM? The normal regex \r and \n do not seem to work. When those are used as replacement strings in WCM, you just get the letters r and n.
I also tried \\r and \\n, but those replace with the literals (\r and \n) as expected.
How does one specify CR or LF in regex replacement strings in WCM?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, it seems that you need to set a special flag for the RegEx library to work with linefeeds. That flag ("Support EOL") is now exposed to the configuration (UI). Please try again. (Implemented in SVN [r1656]).
I then used WCM to convert that replacement from a literal string replacement to a regex replacement. To do so, I went to the regex tab for the replacement item, and entered </item> in the RegEx to replace and </item>\n\n in the ...with field in that same tab.
This does not result in newlines being added to the replacement string, as it should.
It also has the very detrimental effect of causing ALL ignores/replaces after # 194 to disappear from the WCM UI after WCM is closed and reopened.
Within the settings file, WCM causes the replacement item to now appears as:
I don't have a test-case so all I do is providing access to the options of the underlying RegEx lib. I've implemented a RegEx testbed no which will be available with the next release. There, you can test yourself how to setup things for you. If you can't manage to do what you want there, then this is a limitation of the RegEx library itself which I cannot fix.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you please verify this is working for you in v24.04? It's not working for me.
When I perform a regex replace with \n\n, WCM replaces the matched string with nn.
BTW, the example you provided looks invalid. Both From195= and RegEx195= are empty, which WCM does not allow. But perhaps you redacted test strings before posting?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What would be the use-case? For RegEx, you have a special character for linefeed(s) you can use. You can use RegEx for search/replace and ignore. Therefore, in the case you need a linefeed you should not use the from/to but the RegEx option. Line-feeds would need to be escaped which is error-prone. So unless its really needed and there is no work-around I would not want to to implement this. Keep in mind: You can ignore white-spaces which removes extensive CR-LF usage. This might also be of help.
But maybe you come up with a use-case first for me to understand...
Yes, using regex is preferred.
But how does one specify CR or LF in regex replacement strings in WCM? The normal regex
\rand\ndo not seem to work. When those are used as replacement strings in WCM, you just get the lettersrandn.I also tried
\\rand\\n, but those replace with the literals (\rand\n) as expected.How does one specify CR or LF in regex replacement strings in WCM?
Note that I'm using the
Advancedregex flavour.I also tried
\x00cin the regex replacement string, but WCM outputsx00cinstead of hex char00C(carriage return).Last edit: Gitoffthelawn 2023-07-23
OK, it seems that you need to set a special flag for the RegEx library to work with linefeeds. That flag ("Support EOL") is now exposed to the configuration (UI). Please try again. (Implemented in SVN [r1656]).
Related
Commit: [r1656]
How much did you test this?
When I try using
\nin regex replacement strings, it does not work.For example, I had the following literal replacement item (which did not work):
I then used WCM to convert that replacement from a literal string replacement to a regex replacement. To do so, I went to the regex tab for the replacement item, and entered
</item>in theRegEx to replaceand</item>\n\nin the...withfield in that same tab.This does not result in newlines being added to the replacement string, as it should.
It also has the very detrimental effect of causing ALL ignores/replaces after # 194 to disappear from the WCM UI after WCM is closed and reopened.
Within the settings file, WCM causes the replacement item to now appears as:
I don't have a test-case so all I do is providing access to the options of the underlying RegEx lib. I've implemented a RegEx testbed no which will be available with the next release. There, you can test yourself how to setup things for you. If you can't manage to do what you want there, then this is a limitation of the RegEx library itself which I cannot fix.
This should be fixed in SVN now. It happens if you change the type of an ignore.
Can you please verify this is working for you in v24.04? It's not working for me.
When I perform a regex replace with
\n\n, WCM replaces the matched string withnn.BTW, the example you provided looks invalid. Both
From195=andRegEx195=are empty, which WCM does not allow. But perhaps you redacted test strings before posting?