Regex to capture punctuation or space *Solved*
Posted: Sat Aug 08, 2020 12:15 am
So, I'm trying to grab "word**." or some punctuation or a space character, and not "some**word " I'm using "\S\*\*\W" as a search pattern to do this, which should work.
In Livecode "\S\*\*\W" will grab "years**." ending in period.
It will grab "mean**," ending in comma.
But it will not grab "someone** " ending in space.
And "\S\*\*\W" should select all of these.
But anything I try, that works in Expressions (regex tester) app or nvim, will not work in Livecode to regex a space character as an option along with punctuation. And as far as I know, back-references, which would make what I'm trying to do very easy, still isn't an option in Livecode.
Do I need to make another command that runs the same search but just focusing on the space character?
The issue was me, which I eventually figured out
In Livecode "\S\*\*\W" will grab "years**." ending in period.
It will grab "mean**," ending in comma.
But it will not grab "someone** " ending in space.
And "\S\*\*\W" should select all of these.
But anything I try, that works in Expressions (regex tester) app or nvim, will not work in Livecode to regex a space character as an option along with punctuation. And as far as I know, back-references, which would make what I'm trying to do very easy, still isn't an option in Livecode.
Do I need to make another command that runs the same search but just focusing on the space character?
The issue was me, which I eventually figured out
Although I did make the "\S\*\*\W" work by chucking the text into an array by word and putting the "& space" back into the array keys. Worked fine for filtering and replacing, and let me get away with using the one handler to replace all closing tags.The issue was that I kept parsing out the space character I was trying to find and replaceThrowing it into an array by word would've done the same thing. But since I was now doing a replace on a known quantity, after I'd already replaced the unknown punctuation, I just ran a replace for "** " on the text as that was all that was left. Not too elegant, but it works.