Regex help...

Ask how to do things or if a certain feature is available in the program.
Post Reply
raptordog
Posts: 13
Joined: 04 Aug 2018 15:40

Regex help...

Post by raptordog »

Using RJs Regular Expression Creator im trying to create a Regex that will find all text that contain 2 dashes together (--), if the 2 dashes appear at the start of the line (ignoring any whitespace) then the whole line can be included regardless of anything else in it.
Also if the 2 dashes appear after any other text then that also needs to be included upto the end of the line.
IMPORTANT: it needs to ignore the 2 dashes (--) if they are inside double quotes or single quotes.

This is the regex i have, unfortunately its still selecting the dashes when inside quotes....

[^"']?--\p{Any}*?$

And here is some text you can test it on....


-- button to the right of the progress bar and then click Yes when a dialog box appears asking if you really want to cancel. Your scene will then be as it was before the
-- fill started.
-- If your fill total is fairly low or your fill objects are not complex objects then the progress bar may quickly appear and disappear before you get chance to cancel. In which case
-- you can use the Undo button next to the Fill button to restore your scene to what it was before the fill.
--
--
hello
--
mystring = " -- hello there" -- hello there

mystring2 = '-- hello there'
-- mystring = "-- hello there"
--

User avatar
pjj
Posts: 1792
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: Regex help...

Post by pjj »

I give up :( This regex is going to be yuuuge! (The bright side is that I learnt that RJ TE regex code supports lookarounds; somehow I thought it didn't.)

Are you going to use it in a script? Perhaps other approach would be easier, then? Count all quotes on each line and if their number is 0 or even assume you're on the "outside" (maybe watch out for escaped quotes, though).
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

raptordog
Posts: 13
Joined: 04 Aug 2018 15:40

Re: Regex help...

Post by raptordog »

Yes i am planning on using it in a script.

Post Reply