Solved

java regex

Posted on 2013-11-19
6
924 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 26

Accepted Solution

by:
dpearson earned 250 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 35

Assisted Solution

by:mccarl
mccarl earned 250 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 35

Expert Comment

by:mccarl
ID: 39661424
I type too slowly! Sorry Doug, I didn't refresh the page before posting :)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 26

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 26

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which is the latest version of Apache Tomcatl 3 50
Securing Jmx Console and web console 2 64
maven project error 5 48
reverse digits of a number using for loop 5 36
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now