Match dash only if not having "\" on front

Hello,

I have string like below:

description 162544–Los A. Opera Co. - Music
Center-361485-5M-data-note:

I would like to split it by dashes but only those without “” sign.
For thecommand below I would like to get “361485”

cnoa = line.split(’-’)[3]

Is it possible? Thanks in advance!

You can use a negative lookbehind pattern like this:

s = ‘description 162544–Los A. Opera Co. - Music
Center-361485-5M-data-note:’
s.split /(?<!\)-/
=> [“description 162544”, “”, “Los A. Opera Co. \- Music Center”,
“361485”, “5M”, “data”, “note:”]