I am attempting to come up with a regex that captures the following:
var testString = "one . one\.two . one\.two\.three" ;
testString.match(/(\\\.)|([^\.\[\]\s]+)/g );
or perhaps using double-backslashes:
var testString = "one . one\\.two . one\\.two\\.three" ;
testString.match(/(\\\.)|([^\.\[\]\s]+)/g );
and would yield:
one
one\.two
one\.two\.three
or even better, eliminate the backslashes:
one
one.two
one.two.three
But I am not sure how to look for a period but yet ignore a period that is trailing a backslash.
In other words, i am trying to manually build an object path. if the path looked something like this:
myObject.one.one_two.one_two_three
it would be easy, but my object level-names have period characters in them.
so I am trying to split up a string by periods that are not backslashed.
i hope this makes sense. thank you all very much.
testString.split(/\s+\.\s+/)? Then to remove the backslashes (if they are physical backslashes),.map(x => x.replace("\\", "")? By the way, is there some reason you are referring to backreferences in the title of your post? Also, minor point, but what is the purpose ofString()here?var testString = "one . one\.two . one\.two\.three" ;results in a stringone . one.two . one.two.three. The string literal notationvar testString = "one . one\\.two . one\\.two\\.three" ;results in a stringone . one\.two . one\.two\.three, where the backslashes are actual backslash characters within the string value...map(x => x.replace(/\\/g, ""));