aspose file tools*
The moose likes Linux / UNIX and the fly likes Search and replace tip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Search and replace tip" Watch "Search and replace tip" New topic

Search and replace tip

Nicolas Viollin

Joined: Apr 13, 2001
Posts: 6
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

Joined: Jun 02, 2003
Posts: 1923

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

Joined: Apr 13, 2001
Posts: 6
thanks a lot, works perfectly !
I agree. Here's the link:
subject: Search and replace tip
Similar Threads
JtreeTable- displaying nodes of a tree in diff. columns of table
Response time never exceeding 5 seconds requirement in part II
Problem with SQL uqery or DSN
intRange validations