Community
    • Login

    Regex is driving me up the wall

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Anthony BouttellA
      Anthony Bouttell
      last edited by

      I’m having issues with regex.
      I have a series of lines in this form:

      IIf(ISNULL([text1])<>'' And Left(ISNULL([text2]),4)="Appr",[text3]
      

      I want to insert text in between the’]'and the ‘)’ like this:

      IIf(ISNULL([text1],'')<>'' And Left(ISNULL([text2],''),4)="Appr",[text3]
      

      I’ve tried this regular expression

      Find what:    (ISNULL.*\])(*.*)
      Replace with:  \1,''\2
      

      apparently tagging doesnt appear to work the way I thought it did.
      Any help would be greatly appreciated

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Anthony Bouttell
        last edited by Scott Sumner

        @Anthony-Bouttell

        One problem is that your use of .* is grabbing too much. You’ll want to change that to .*? which will match the minimum amount. And then the *.* looks too much like CMD shell wildcard/globbing…

        I’m away from Notepad++ at the moment so I can’t actually try it out, but maybe something like this will work, or at least give you a boost:

        Find-what zone: ISNULL.*?\]
        Replace-with zone: $0,''

        In words: match ISNULL through the immediately following closing bracket, replace the match with what was found (represented by $0) plus a comma and two single-quotes.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors