TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:18790] quick way to strip spaces...




Forgot to include an answer...


> I also am going to need to strip out '(' and ')', and I'm not seeing how to
> do that.  

The substitution operator, s///, says to substitute the pattern that's
matched by the expression between the 1st and 2nd `/' chars with the
expression between the  the 2nd and 3rd `/' chars. 

So, to replace "A" with "B", you'd do s/A/B/.

For your problem, you're using special chars, (), and so they need to be
marked as such by using a backslash before them:

	s/\(|\)//;

... which properly escapes the characters you want to match. That also
uses alternation (the "|")in the matching expression, saying in effect "if
you match either ( or )". Since you're stripping these chars out of the
name, you're replacing them with nothing.

Hope that helps.

Andy

> Brian