Regular Expressions

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Regular Expressions

  • Creator
    Topic
  • #48984
    Keith McLeod
    Participant

    Any recommendations for good regular Expression books?  I am finding that many interfaces have a significant call for the use of regular expressions.

    Or better yet any tools for this?

    Latest request to find ‘(NOTE:)10/27/06)’ and put a ~ right after this.  Somtimes the date is there and sometimes not.

    Also have mutli lab results with different formats with no line break characters.  Some are identified by 3 spaces, some have 12 spaces as the beginning of the new lines.  SO I would like to find exactly 12 spaces and replace with ~ and 12 spaces.  On e the smaller side I would like to find exactly 3 spaces and replace with ~ and 3 spaces…..I think Regular expressions could help in getting these formats more correct.  Thanks…

Viewing 5 reply threads
  • Author
    Replies
    • #60319

      Practical Programming in  Tcl and Tk by Welch/Hobbs

      Mastering Regular Expressions by Jeffrey E.F. Friedl (O’Reilly)

      Google by Goole 🙂

      -- Max Drown (Infor)

    • #60320

      Code:

      set line “(NOTE:)10/27/06”
      #set line “(NOTE:)”
      regsub {((NOTE:).*$)} $line {1~} line
      puts $line

      -- Max Drown (Infor)

    • #60321

      Code:

      set line ”            ”
      regsub {( {12})} $line {~1} line
      puts $line

      Code:

      set line ”   ”
      regsub {( {3})} $line {~1} line
      puts $line

      These are just simple examples, but you should probably add some anchors if possible (like ^ and $) to help eliminate invalid matches.

      -- Max Drown (Infor)

    • #60322
      Jamin Gray
      Participant

      Code:


      regsub {(NOTE:)(d{2}/d{2}/d{2})?)} $x {~} x

      where $x is your string.  This one is a bit more specific about the pattern, looking for the optional date instead of just any text.  And it illustrates the escape in the replacement which evaluates to all of the match.

    • #60323

      … or to cover cases where only one digit is used for month or day and 2 or 4 digits for year …

      Code:

      regsub {(NOTE:)(d{1,2}/d{1,2}/d{2,4})?)} $x {~} x

      -- Max Drown (Infor)

    • #60324
      Steve Carter
      Participant

      Regular Expression Pocket Reference by O’Reilly is also a handy one to have around.

Viewing 5 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10