Skip to main content
Solved

Replace first / (A) and second / (B)

  • March 10, 2021
  • 2 replies
  • 25 views

hoa_le
Contributor
Forum|alt.badge.img+5

Hi all,

I want to replace in this:

12/3 >> 12 A 3

13/2/5 >> 13 B 2 A 5

Could you show me how to make regex? Thank you

Best answer by david_r

The easiest is probably to use two separate StringReplacers, one for each case.

 

One slash:

Search for: ^(\d+)/(\d+)$
Replace with: \1 A \2

Two slashes:

Search for: ^(\d+)/(\d+)/(\d+)$
Replace with: \1 B \2 A \3

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • Best Answer
  • March 10, 2021

The easiest is probably to use two separate StringReplacers, one for each case.

 

One slash:

Search for: ^(\d+)/(\d+)$
Replace with: \1 A \2

Two slashes:

Search for: ^(\d+)/(\d+)/(\d+)$
Replace with: \1 B \2 A \3

 

 

 


hoa_le
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 10, 2021

The easiest is probably to use two separate StringReplacers, one for each case.

 

One slash:

Search for: ^(\d+)/(\d+)$
Replace with: \1 A \2

Two slashes:

Search for: ^(\d+)/(\d+)/(\d+)$
Replace with: \1 B \2 A \3

 

 

 

Thank you so much