Hi all!

I need to create regex that matches everything before some specified (whole) word. Lets say I need everything before 'have' in such text:

What ^7^*#/> I @@3->;: have to do with this *~~@}}], hmm...?

...so I would like to have "What ^7^*#/> I @@3->;: " as a result - weird symbols inside the example are just to show what are we dealing with (it is not plain text, like "plain text")

It seems not so easy, though...
ideas?

YourString.Substring(0, YourString.IndexOf("have"))

but you must handle what if "have" does not exist , i think it will give you error

I formulated the example so easy so you understand what I need. Now, I think I made it too easy...

Thanks for your reply, but I need to use Regex to do this, like I wrote on the top. The problem is actually solved, as I've sent it to many forums :) Your idea would be the BEST solution if my problm would be like the one above and nothing more.

Thanks again for your reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.