0

Apologies, I've tried - and it might just be me being a bit dense, but I just can't get my head around it.

I've got some data in a format similar to:

Some Text L1234
Some Other Text L5587

I need to replace the L in the final group to be an A (it's always Ldddd at the end).

(L[0-9]{4})

to find the group was as far as I got, I've no idea how to then replace the L!!!

Thanks in advance

Mike
  • 11
  • 2
  • 1
    Possible duplicate of [Learning Regular Expressions](https://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Dec 05 '18 at 15:19
  • 2
    What OS/editor/RDBMS/etc are you doing this in? Where does the data reside, in a file? variable? column? How many will be operated on at a time? Not all regular expression engines are created equal. – Gary_W Dec 05 '18 at 15:31
  • use ([\w].*)(L)(\d{4}$) regex to find the matching characters and \1A\3 to replace L with A – Abhishek Patyal Dec 05 '18 at 15:33

1 Answers1

-1

Use this regex,

L(?=\d{4}$)

and replace it with 'A'

This look ahead (?=\d{4}$) makes sure, only L is selected for replacement which is followed by exactly 4 digits and end of string.

Demo

Pushpesh Kumar Rajwanshi
  • 18,127
  • 2
  • 19
  • 36