Community
    • Login

    Regex is driving me up the wall

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.3k Views 2 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors