Tuesday, August 31, 2010

Useful Regular Expressions

  • Select shell (FLOOR) named "Level_8" and all spaces following, up to "Level_9"

    (?s)(^"Level_8.*)(?=^"Level_9)

    Note that (?s) enables multi-line matching, and (?= begins a non-capturing group
  • Match all EL1 walls and reformat with space vertex identifier

    (?s)(^"EL1\s)(\w{1,20}\s)(Wall\s.{1,5}\..{1,9}\.)(.{1,9})(\)"\s{1,20}\=\s)(\w)(.{5,100}SPACE\-)(V\d{1,2})

    Replacement String: \1\6\3\8\5\6\7\8
  • Strip least-significant identifier from Roof / Flr components:

    (^"EL\d\sRoof\s\(.{1,9}\..{1,9})(\..{1,9}\)")
    (^"EL\d\sFlr\s\(.{1,9}\..{1,9})(\..{1,9}\)")

    Replacement String: \1)"

No comments: