Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Regular Expression help!

Reply
Thread Tools

Regular Expression help!

 
 
shilpa
Guest
Posts: n/a
 
      09-15-2005
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?

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-15-2005
On 14 Sep 2005 23:46:07 -0700, "shilpa" <(E-Mail Removed)> wrote
or quoted :

>
>Is it possible by using Regular expression?


see http://mindprod.com/jgloss/regex.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-15-2005
On 14 Sep 2005 23:46:07 -0700, "shilpa" <(E-Mail Removed)> wrote
or quoted :

>Is it possible by using Regular expression?


Yes. To find out how, see http://mindprod.com/jgloss/regex.html

You need to learn regex as a whole.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      09-20-2005

"shilpa" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments