Loading ...
Sorry, an error occurred while loading the content.

[NTB] (Offtopic)? (g?awk|regexp) problem

Expand Messages
  • Sami Järvinen
    I m new to g?awk, please be gentle ;) Here s a small g?awk script I m working on: { if ((i = match( $0 , / n]/ )) != 0) { foo = substr( $0,
    Message 1 of 1 , Jul 30, 1998
    • 0 Attachment
      I'm new to g?awk, please be gentle ;)

      Here's a small g?awk script I'm working on:

      if ((i = match( $0 , /<\/?[a-zA-Z0-9]+[> \n]/ )) != 0)
      foo = substr( $0, 1, i-1 )
      j = match( $0, /[> \n]/ )
      bar = toupper( substr( $0, i, j-1 ) )
      baz = substr( $0, j )
      print foo bar baz

      It's supposed to convert HTML tags to upper case (the name only, not
      attributes). Example:

      <hr width="75%">

      should become

      <HR width="75%">

      Now the thing is that it does handle the above code, but when I tried it
      with a whole HTML document, it produces stuff like this:


      I know that the script would only handle the first tag on each line if
      it worked, that's not the issue (and I don't want you to tell me how to
      fix this!). If someone could just

      1) tell me what is wrong with the current code and
      2) give me some tips if there're more elegant ways to do this stuff,

      that'd make me very happy.

      Read this list on the Web at http://www.makelist.com/list/notetab/
      To unsubscribe, email to notetab-unsubscribe@...
      To subscribe, email to notetab-subscribe@...
      Start a FREE E-Mail List at http://www.makelist.com !
    Your message has been successfully submitted and would be delivered to recipients shortly.