aspose file tools*
The moose likes Java in General and the fly likes how to match the regular expression using if Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to match the regular expression using if " Watch "how to match the regular expression using if " New topic
Author

how to match the regular expression using if

deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
hi,

i have an coding like this using regular expression.but i want to match it using if statement.





i need it to match the same using if condition statement can any one tell me how to do this using if statement?

[Edit - added code tags - see UseCodeTags for details]
deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
Dear experts,

i have tried an code using if to match the word java and print that word java using if statment to match and get the output window as

JAVA

the code i have tried is as follows.but it show's some errors and i have no idea how to proceed.can you tell me how to proceed and i could not find any code like this for matching.



am i correct or if i am wrong what can i do and how to proceed to get an output using if conditional statement?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

vijayalakshmi deepika wrote:
i have tried an code using if to match the word java and print that word java using if statment to match and get the output window as

JAVA

the code i have tried is as follows.but it show's some errors and i have no idea how to proceed.can you tell me how to proceed and i could not find any code like this for matching.



am i correct or if i am wrong what can i do and how to proceed to get an output using if conditional statement?



To start, what language are you trying to code in???



This code looks like a combination of C++ and Javascript.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
i want to code in java using if conditional statement and match the regular expression and get the output of first string alone as Java.but i don't know how to match it using if condition and get the output.

if it's combination of JavaScript and C++.How to code this sentence in java

String sentence = "<name>Java</name> has methods";

and get the output as
Java alone using matching and leave has methods.

how to do it?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

vijayalakshmi deepika wrote:i want to code in java using if conditional statement and match the regular expression...


Even this part of your question is impossible to understand. Could you please stop saying that and try saying something else which people could have a chance at understanding?

You don't use an if-statement to match a regular expression. Not in Java, anyway, and that's what we are talking about here. In Java you have to call some methods to match a regular expression. So your insistence on using an if-statement just makes no sense at all, since that has nothing to do with matching a regex.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

vijayalakshmi deepika wrote:i want to code in java using if conditional statement and match the regular expression and get the output of first string alone as Java.but i don't know how to match it using if condition and get the output.

if it's combination of JavaScript and C++.How to code this sentence in java

String sentence = "<name>Java</name> has methods";

and get the output as
Java alone using matching and leave has methods.



Also, please read this... http://www.coderanch.com/how-to/java/ShowSomeEffort. Java ranch is a learning site, generally, you have to attempt it first, and we give hints to get you in the right direction. If this is not valid Java code, meaning you haven't even used the compiler yet, how can we know where you were you went wrong?

Henry
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to match the regular expression using if