Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

java regex

Posted on 2013-11-19
6
934 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 27

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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 27

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 27

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
session migration servlets 2 42
tomcat startup error 5 102
How to determine if a string is a valid SHA value 7 35
Glassfish admin console not working 1 32
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

861 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