• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to match the regular expression using if

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 23949
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Marshal
Posts: 28138
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23949
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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... https://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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic