Skip to main content
Question

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

  • March 2, 2017
  • 1 reply
  • 20 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

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 2, 2017

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.


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