Question

Can I use String replacer to add a character between two regular expessions?

  • 2 March 2017
  • 1 reply
  • 6 views

Hello,

 

 

I need to reformat some strings.

3/2-A1 needs to become 3/2-A01. Where I have a dash followed by a letter followed by a number I want to replace it by dash, the same letter, 0, then the same number.

I can find my string using a regular expression :

-[A-Z][1-9]

and I've tried -[A-Z]0[1-9] in the Replacement text box of String Replacer but (unsurprisingly that just gives me

3/2-[A-Z]0[1-9]

Is there away to search for the whole regex, but only replace part of it?


1 reply

Badge +22

text to match: (-[A-Z])([1-9])

 

replacement text: \\10\\2

 

 

putting parentheses around sections creates parts, and then you can refer to the parts as \\1, \\2 etc.

Reply