![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to change every 3rd character | manas_ranjan | Shell Programming and Scripting | 2 | 12-15-2007 06:18 AM |
| Trying to remove single character from a line | Iz3k34l | UNIX for Dummies Questions & Answers | 5 | 07-07-2007 01:29 PM |
| change character case | ajaya | UNIX for Dummies Questions & Answers | 3 | 03-23-2006 03:22 PM |
| Single character wildcard for SED | stevefox | Shell Programming and Scripting | 8 | 02-16-2006 01:23 AM |
| reading a single character in C | alodha | High Level Programming | 3 | 01-28-2005 06:22 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I know this is strictly a programming forum - but I consider vi a programming enabler and the question relates to regex you'd use with awk/sed anyway....
I have a file which is 50,000+ lines long and need to change many many instances of word_word_word to be word+word+word where 'word' can be any 'word' and it is the underscore character that needs to be changed to a plus character. I'm happy with :1,$ s/some pattern/new pattern/g type changes, but can't seem to nail this. I've tried :1,$ s/[Aa-Zz]_[Aa-Zz]/[Aa-Zz]+[Aa-Zz]/g but that puts many [Aa-Zz] patterns in the file...... Any help humbly appreciated. ----------------------------------------------------------- Brett |
|
|||||
|
quoting from 'man regexp':
Code:
1.4 A non-empty string of characters enclosed in square
brackets ([]) is a one-character RE that matches any
one character in that string. If, however, the first
character of the string is a circumflex (^), the one-
character RE matches any character except new-line and
the remaining characters in the string. The ^ has this
special meaning only if it occurs first in the string.
The minus (-) may be used to indicate a range of con-
secutive characters; for example, [0-9] is equivalent
to [0123456789]. The - loses this special meaning if
it occurs first (after an initial ^, if any) or last
in the string. The right square bracket (]) does not
terminate such a string when it is the first character
within it (after an initial ^, if any); for example,
[]a-f] matches either a right square bracket (]) or
one of the ASCII letters a through f inclusive.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|