?
Solved

java regex

Posted on 2013-11-19
6
Medium Priority
?
965 Views
Last Modified: 2013-11-25
Hi,

I was going through below link

http://www.tutorialspoint.com/java/java_regular_expressions.htm

Does java java regular expresssion is part of new java release or is it there from long time.

why we use regular expression. What are advantages, disadvantages, practical uses, alternative ways to it.

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 3
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
dpearson earned 1000 total points
ID: 39661414
Java regular expressions have been in the language since version 1.4 (a long time ago now).

You can see this for any Java class by looking in the docs:
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html

Has a line:

Since:
1.4

which shows when it was added to the Java language.

Regular expressions are used when matching patterns in strings.  That comes up a lot in programming - e.g. making sure that a phone number follows the pattern:

(nnn) nnn-nnnn

can be easily checked with a regular expression.

They are also very fast when doing operations like scanning a big document for a specific pattern (e.g. find the first place where "Thanks" occurs before "advance" in a web page).

Much faster than code you would write yourself to do this - by perhaps getting the first character of the page, see if it's a "T".  If not, get the next character etc.

So they are good things to learn and use.

Doug
0
 
LVL 36

Assisted Solution

by:mccarl
mccarl earned 1000 total points
ID: 39661419
Does java java regular expresssion is part of new java release or is it there from long time
A quick read of the Javadoc for the java.util.regex package says that the package and the classes within have been available since Java v1.4

http://docs.oracle.com/javase/7/docs/api/java/util/regex/package-summary.html

why we use regular expression
To allow quite flexible and potentially complex matching operations on a sequence of characters. And can also be used to perform replacement of found matches and possibly capture and return some part(s) of the found match. And plenty of other uses, I'm sure.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 39661424
I type too slowly! Sorry Doug, I didn't refresh the page before posting :)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 28

Expert Comment

by:dpearson
ID: 39661447
Haha - great minds think alike mccarl!

Doug
0
 
LVL 7

Author Comment

by:gudii9
ID: 39670090
They are also very fast when doing operations like scanning a big document for a specific pattern (e.g. find the first place where "Thanks" occurs before "advance" in a web page).

I have not understood this use case. what is the meaning of 'Thanks' occurs before "advance".

Please advise
0
 
LVL 28

Expert Comment

by:dpearson
ID: 39670870
I have not understood this use case. what is the meaning of 'Thanks' occurs before "advance".

It was just an example - searching for the word "Thanks" occurring somewhere in a document before the word "advance"

Thanks for helping.    // No match
Thanks in advance.    // Match - but notice how the words aren't next to each other

It's not that easy to write code to do this yourself.  But regular expressions handle it really well.

Doug
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question