Skip to main content



      Home
Home » Newcomers » Newcomers » Using regular expressions
Using regular expressions [message #250399] Thu, 28 February 2008 16:23 Go to next message
Eclipse UserFriend
Hi,
I have a constructor which takes a string as an argument. I want to
replace the string with a regular expression.How do I do this in java. I
have read about the package java.util.regex . But was unable to figure out
how this task could be done.
Thanks
Junaid
Re: Using regular expressions [message #250406 is a reply to message #250399] Thu, 28 February 2008 16:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Junaid,

This is just a basic beginner's Java question, not a question about
Eclipse. It's probably best to Google for this stuff and find some nice
tutorials about them. There are plenty.

Junaid wrote:
> Hi,
> I have a constructor which takes a string as an argument. I want to
> replace the string with a regular expression.How do I do this in java.
> I have read about the package java.util.regex . But was unable to
> figure out how this task could be done.
> Thanks Junaid
>
Re: Using regular expressions [message #250537 is a reply to message #250406] Fri, 29 February 2008 13:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,
Actually I was developing an editor which is used to create files.
The SingleLineRule constructor takes an arguments as String
startsequence,String endsequence,Token.
I want to replace the startsequence with a regular expression.
Example on the editor wud be
abc = 10
I want to validate whether user entered only alphabets before the equals
sign.
I could use the single line rule as SingleLineRule("[a-z][A-Z]*","=",Token)
but I need to compile the regular expression before using it.
How do I do this?
Is there any other method using which I could complete my task.
Thanks
Junaid
Re: Using regular expressions [message #250553 is a reply to message #250537] Fri, 29 February 2008 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Junaid,

You mean java.util.Pattern.compile(String)?

Junaid wrote:
> Hi Ed,
> Actually I was developing an editor which is used to create files.
> The SingleLineRule constructor takes an arguments as String
> startsequence,String endsequence,Token.
> I want to replace the startsequence with a regular expression.
> Example on the editor wud be abc = 10 I want to validate whether user
> entered only alphabets before the equals sign.
> I could use the single line rule as
> SingleLineRule("[a-z][A-Z]*","=",Token)
> but I need to compile the regular expression before using it.
> How do I do this?
> Is there any other method using which I could complete my task.
> Thanks
> Junaid
>
Re: Using regular expressions [message #250611 is a reply to message #250553] Fri, 29 February 2008 17:31 Go to previous messageGo to next message
Eclipse UserFriend
Yes using Pattern class to complie the regular expression.
Re: Using regular expressions [message #250615 is a reply to message #250553] Fri, 29 February 2008 17:34 Go to previous message
Eclipse UserFriend
What ever is typed on the editor should be validated against a regular
expression.
Previous Topic:Newsgroup search broken on newsportal
Next Topic:How do I install a GlassFish adapter?
Goto Forum:
  


Current Time: Wed May 14 23:17:34 EDT 2025

Powered by FUDForum. Page generated in 0.31331 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top