Braces within a string 
Author Message
 Braces within a string

I have a problem where I have a fixed field (i.e., $12) that contains either
a string (i.e., JOE) or a string enclosed in braces (i.e., {JOE IS NOT
HERE}) I am having trouble using gsub or gensub in awk to change the field
to something I can use. I can't access the filed properly if there is
multiple words in the field.  Is there a good way of changing the braced
string with a constant? (i.e., {JOE IS NOT HERE} changes to TEST)


Sun, 25 Dec 2005 12:38:07 GMT  
 Braces within a string

Quote:

>I have a problem where I have a fixed field (i.e., $12) that contains either
>a string (i.e., JOE) or a string enclosed in braces (i.e., {JOE IS NOT
>HERE}) I am having trouble using gsub or gensub in awk to change the field
>to something I can use. I can't access the filed properly if there is
>multiple words in the field.  Is there a good way of changing the braced
>string with a constant? (i.e., {JOE IS NOT HERE} changes to TEST)

how about something like this:

sub(/[{][^}][^}]*[}]/,"TEST",$0)

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,

  Die Anyway         |    v    | That no one could find fault with it.



Mon, 26 Dec 2005 07:07:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Ada String Issue: String within Strings

2. Order of evaluation with curly braces within quotes

3. string variable within a string

4. string variables within strings

5. String insert within a string (src code included)

6. Brackets in brackets, braces in braces

7. Brackets in brackets, braces in braces

8. passing a prolog string to tcl and unbalanced braces

9. unbalanced braces when passing a prolog string to tcl

10. Help using [ as a string character not a Command Brace

11. syntax parser in tcl8.1 - wrong usage of braces in comments or strings

12. Matching strings that contain braces

 

 
Powered by phpBB® Forum Software