[CS-FSLUG] regexp help
Eduardo Sanchez
lists at sombragris.org
Thu Nov 11 12:28:48 CST 2004
Tim, Thanks!!!
I'm going to try these.
Eduardo
On Thursday 11 November 2004 20:55, Tim Young wrote:
> There are a zillion ways to do this. If all hyphens are used this
way, the
> simplest is:
>
> cat [myfile] | sed 's/-/--/g'
>
> If you are in vi., the same command is:
> :%s/-/--/
>
> But if you need to do it only when there is a worda-wordb, you can do
this:
> cat [myfile] | sed 's/([a-Z0-9][a-Z0-9]*)-([a-Z0-9]
[a-Z0-9]*)/\1--\2/g'
>
> and in vi:
> :%s/([a-Z0-9][a-Z0-9]*)-([a-Z0-9][a-Z0-9]*)/\1--\2/g
>
> I believe these work. I am away from my linux box at the moment... :
(
>
> - Tim
>
> Eduardo Sanchez wrote:
>
> > People, I'm stuck in a rut, and I need the help of the regexp
wizards
> > here.
> >
> > I have some strings as follows:
> >
> > wordA-wordB
> >
> > That is, two words (or numbers, or practically any ASCII char)
joined by
> > a hyphen.
> >
> > What I would need to do is to perform a search and replace so that
the
> > above string is changed to:
> >
> > wordA--wordB
> >
> > that is, I need to search instances of a single hyphen and replace
it
> > with a double hyphen. I know there's some regexps I could use, but
now
> > I'm stuck and I don't know even where to begin.
> >
> > Any help will be greatly appreciated.
> >
> > Thanks in advance,
> >
> > Eduardo
> >
> > --
> > Prof. Eduardo Sanchez
> > Asuncion, Paraguay, South America
> > --------------------------------------------------------------
> > For "Is" and "Is-not" though with Rule and Line
> > And "UP-AND-DOWN" by Logic I define,
> > Of all that one should care to fathom, I
> > was never deep in anything but--Wine.
> >
> > -- The Rubaiyat of Omar Khayyam
> >
> >
> > --------------------------------------------------------------
> >
> > _______________________________________________
> > ChristianSource FSLUG mailing list
> > Christiansource at ofb.biz
> > http://cs.uninetsolutions.com
>
>
> _______________________________________________
> ChristianSource FSLUG mailing list
> Christiansource at ofb.biz
> http://cs.uninetsolutions.com
>
--
Prof. Eduardo Sanchez
Asuncion, Paraguay, South America
--------------------------------------------------------------
The Moving Finger writes; and, having writ,
Moves on: nor all thy Piety nor Wit
Shall lure it back to cancel half a Line,
Nor all thy Tears wash out a Word of it.
-- The Rubaiyat of Omar Khayyam
--------------------------------------------------------------
More information about the Christiansource
mailing list