Jump to content
UBot Underground

Regex Problem Matching 2 Cases


Recommended Posts

Hi,

 

I'm a bit lost (again) :D in a regex.

 

I have this test string: Menu item 1[Test]

The test string could also be just: Menu item 1

 

I have made this regex: .*?(?=\[.*\])

 

This works perfectly in the first case. I get: "Menu item 1" as I wanted.

 

But in the second case where there is no [Test] in the string, it returns nothing - no match.

I'm looking to match everything but this pattern: [.*]

 

Is that really so hard, or is it just me?  :D (don't answer that)... 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...