Regular Expression help!

S

shilpa

Hello,

I am trying to parse string buffer by using Regular Expression.
Suppose my string buffer is:

-------------------------------------------
Hi , How are you?

Hello: abc

hurrey : [ this is test msg
Pls reply to this mail
Hello: xyz
Test1
]

-------------------------------------------

I want to search string: "Hello: anystring till end of line" which is
not included in [].
So In above example my Regular expression should only find

first "Hello: abc".

Is it possible by using Regular expression?
 
O

Oliver Wong

shilpa said:
Hello,

I am trying to parse string buffer by using Regular Expression.
Suppose my string buffer is:

-------------------------------------------
Hi , How are you?

Hello: abc

hurrey : [ this is test msg
Pls reply to this mail
Hello: xyz
Test1
]

-------------------------------------------

I want to search string: "Hello: anystring till end of line" which is
not included in [].
So In above example my Regular expression should only find

first "Hello: abc".

Is it possible by using Regular expression?

I don't think this is possible, particularly if you allow nesting of
brackets. Consider:

[[[[]]]
Hello: How are you?
[[[]]]]

This requires bracket-balancing, which requires at least the power of a
context-free grammar, so no, regular expressions are not powerful enough to
accept this language.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top