File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to match the regular expression using if

 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic