Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search and replace tip

 
Nicolas Viollin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there !

I've got many string like this 'xxxxyyyzzz'. 'xxxx' and 'zzz' are fixed part of the string, they're always the same.

I would like to replace that 'xxxxyyyzzz' string with this 'xxxxyyyzzzwwww' string.

How do i tell the S&R to keep the mobile part of my string and simply add the 'wwww' part ?

to be clear, here are exemples:


'Mike125NAT' where 'Mike' is 'xxxx', '125' is 'yyy' and 'NAT' is 'zzz' would become 'Mike125NATFive'
'James007Bond' where 'James' is 'xxxx', '007' is 'yyy' and 'Bond' is 'zzz' would become 'James007BondLicencedtokill'

thanks for your help !
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is the variable-part allways 3 characters long, then use ... instead of .*, is it allways made of digits, use [0-9]*, is it something, except a blank, use [^ ]* .

May there be multiple replacements in a row, use 'g' for global as postfix-operator:


 
Nicolas Viollin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot, works perfectly !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic