Author Topic: Question about find and replace with regular expression  (Read 8846 times)

kenbr1960

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Question about find and replace with regular expression
« on: June 22, 2014, 08:50:52 PM »
I am trying to do a find/replace using this unix regular expression search.

Y...." TO READ-VAR2

The search works fine but the problem is the '....' will match any pattern but in my replace I want to change the 'Y' to an 'N' but leave the other characters alone and I can't figure out if there is a way to this. As an example I have these two lines:

MOVE "1200Y0000000YSTX1" TO READ-VAR2.
MOVE "1200Y0000000YDEF " TO READ-VAR2.

I would liked to do a find/replace in files that would find and change these two lines to this

MOVE "1200Y0000000NSTX1" TO READ-VAR2.
MOVE "1200Y0000000NDEF " TO READ-VAR2.

If I do a search in files I'm finding around 80 lines throughout the files that I need to change. I'm just wondering if anyone knows of a way to do this.


hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Question about find and replace with regular expression
« Reply #1 on: June 23, 2014, 07:25:37 AM »
use tagged groups
e.g.
Code: [Select]
search:  Y([A-Z].+)(" TO READ-VAR2)
replace: N\1\2
HS2

kenbr1960

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Question about find and replace with regular expression
« Reply #2 on: June 26, 2014, 11:08:04 AM »
Thanks!