Skip to main content
Solved

Select AND Replace with a RegEx Expression


Forum|alt.badge.img

Hello,

 

 

I have an attribute that has values like this (the attribute itself is RegEX expression):

^[1-9]{1}[0-9]{1-3}[1-9]{1}[0-9]{5-7}$

In this attribute I want to replace all - that are within {} with a ,

 

 

I tried using the String replacer by first selecting all curly brackets with dashes, like this :

\\{\\d-\\d\\}

And then replacing it with this:

\\{\\d,\\d\\}

But of course it does not work cause you cannot replace with regex.

 

 

Any ideas?

 

 

Thanks !

 

Best answer by gio

@draganasubotic1

You can use stringreplacer, Replace Regular Expression.

regexp:

({[\\d])-([\\d]})

and replacement

\\1,\\2

Everything between brackets is a capture, of which there are 2 in this case.

Captures can be referred to by slashes, \\1 is first capture.

View original
Did this help you find an answer to your question?

3 replies

Forum|alt.badge.img

I guess you want to replace all dashes which are in the curly brackets with "," (comma).

You can use the expression below:

(?<=\{\d)\-

0684Q00000ArJlNQAV.jpg


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • Best Answer
  • May 25, 2018

@draganasubotic1

You can use stringreplacer, Replace Regular Expression.

regexp:

({[\\d])-([\\d]})

and replacement

\\1,\\2

Everything between brackets is a capture, of which there are 2 in this case.

Captures can be referred to by slashes, \\1 is first capture.


Forum|alt.badge.img

Thanks a lot, both answers were very helpful!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings