Page 1 of 1

sandr question

Posted: Tue Apr 10, 2007 1:22 pm
by basement_addict
Hi,

If I have this string

+W+R +otherterm +moreterms

I am trying to remove single char terms that are prefixed by a + and followed by a space. I don't want to remove the "+R " above since the term being searched on is "W+R".

If the string was:
+A +otherterm +moreterms

I would want the "+A " removed

But if the string was:

+C +otherterm +moreterms

I would want to keep the "+C " since C is the only 1 character term we allow searching on (C programming).


This is my starting point

<sandr "\+[0-9ABD-Zabd-z]\space" "" $var>


Thanks.

sandr question

Posted: Tue Apr 10, 2007 2:29 pm
by mark
Start by putting leading and trailing space on.
<strfmt " %s " $var><$var=$ret>
Then your expression with a leading space should work
<sandr "\space\P=\+[0-9ABD-Zabd-z]=\F\space" "" $var>
leave the spaces in so terms don't get run together.