I am using http://www.regexr.com/ and https://regex101.com/ to learn regex
regex101's Quick reference shows
Conditional statement: (?(...)|)
If the given pattern matches, matches the pattern before the vertical bar. Otherwise, matches the pattern after the vertical bar.
I can't get it to work at all
/(^(?!no)if|else)/gm
no if else
yes if else
looks like its broken
/(?:(yes)true|false)/g
yes true false
I need to return a single match using string.match so I stay compatible with a third party. I don't have the option to do anything with the results myself so I won't be able to do multiple regex nor filter results with javascript. what I would like to achive is a regex that asks for
if the sentence starts with the word 'name' or the sentence contains '.classX' then return nothing else return '.classA'
returning eather [""] or [".classA "]
Is this possible at all or am I completly waisting my time?
Aucun commentaire:
Enregistrer un commentaire