Chunjee wrote: ↑20 Nov 2019, 07:21
mojobadshah wrote: ↑20 Nov 2019, 00:06
Neither \n or 'n is a recognized regex expression in this setting for rendering a newline in a character string. What regex expression should I use to form a newline in a string of text?
\n is acceptable.
https://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm also mentions ") Circumflex (^) matches immediately after all internal newlines" when using the Multiline option, which is done at the start of the pattern unlink js which is done after the / at the end of the pattern.
https regex101.com /r/FCd6q5/2 Broken Link for safety
which would be the following in ahk: "
m)\w*\s\w*\n\w*"
Notepad/Windows often saves newlines as \n\r so that often trips people up. I usually convert all \r to \n in memory before performing regex as a way to keep regex patterns from getting too complex.
This is the only thing that makes sense to me in terms of your response. The first two instances (and generally a lot of ahk regex don't appear to correspond to js regex very realistically). My presumption in respects to the last option is that this option speaks to having to write a ahk regex script that is much more expansive where \n is not actually recognized as a regex expression, rather \n could really be interchangeable with any real character (eg. regular text) - it's really a 'hashtag' that is what is being identified in the last option
{
Data := RegExReplace(Data, "([<])","\n$1")
}
[/code]
So, the way things are scripted now something like 'Mary<John<Mary' in a text string will resolve to 'Mary\n<John\n<Mary,' and I can see how I can implement another function similar to the one directly above, but a bit more complicated. Haven't mastered the technique, but I noticed something that involved a "Loop, Parse" effort like this
Code: Select all
Loop, Parse, Data, `n, `r
{
if RegExMatch(A_LoopField, "(\w+)", Match )
Data .= A_LoopField "`n"
}
And this almost works in reference to the indicated 3rd option to make use of extra characters eg. \n (which would otherwise service directly as a ahk expression, normally represented as 'n within ahk's coding language system) as substitute hashtags. My question in relation to this method is - is this the only way to actually 'add' newlines into a string of text, and if so how do I make this 'Loop, Parse' function conform to the RegExReplace function I've provided above as a 2nd sequence? Otherwise, what do I add to the initial RegExReplace function that I provided so that \n does not resolve to actual \n in ahk results, but rather pushes or splits text to form an actual newline in a text?