in reply to Re: Regex with Backslashes (updated)
in thread Regex with Backslashes
Thanks for taking the time to point out the issues with my presentation of strings, which has caused confusion.
If I post again I will take your advice on the presentation and the use of quoting.
Having considered the problem I originally posted, I have decided that I should take a slightly different approach which I touched on in a response to another monk, and my data will use two commas where a non-splitting comma is required and two backslashes where a backslash is required. This changes the regex requirements substantially.
My data would look like this: 1,Text,,with,,commas,X,99 and my regex is: my $regex = qr /(?<!,),(?!,)|(?<=,,),/;
This is working in my script with this output:
1 Text,,with,,commas X 99
Thank you to all who responded.
Maybe I will take the plunge and post my 'lcd daemon with battery meter script' once it is completed. Not exactly an Earth-shattering piece of work, but quite fun.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Regex with Backslashes
by haukex (Archbishop) on May 18, 2020 at 19:51 UTC | |
by anita2R (Scribe) on May 18, 2020 at 20:20 UTC | |
by haukex (Archbishop) on May 18, 2020 at 20:29 UTC | |
by anita2R (Scribe) on May 18, 2020 at 21:04 UTC | |
Re^3: Regex with Backslashes (updated)
by AnomalousMonk (Archbishop) on May 18, 2020 at 19:08 UTC | |
by anita2R (Scribe) on May 18, 2020 at 19:23 UTC |