dyvel 20 Posted January 7, 2015 Report Share Posted January 7, 2015 Hi, I'm a bit lost (again) 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? (don't answer that)... Quote Link to post Share on other sites
dyvel 20 Posted January 7, 2015 Author Report Share Posted January 7, 2015 And here's the solution: ^[^\[]+ 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.