Register | Log in | RSS channel for codegravity.com homepage Bookmark!

284/2NEW projects | 71 services | 215 websites | 834/3NEW freelancers | 2126 topics | advertise



Login:



Forgot your password?
Forgot your username?
Create an account
JoomlaWatch Agent

Users

Most active users today from total of 108:
garikello, Peerke, jakkrit, dayanand, andrew_saber, giakhanh, mohalb, carmachhh, fguyon, dfireablaze, boho, phoeker, ozedfr, ashish_php, amoluca, blackie, JDev, tinytim007, Pascale, besoil


19.9%United States United States
17.9%India India
9.3%Germany Germany
5.5%Russian Federation Russian Federation
4.4%United Kingdom United Kingdom
4.3%France France
4%Australia Australia
3.8%Netherlands Netherlands
3.8%Poland Poland
3.7%Italy Italy

Today: 953
Yesterday: 1402
This Week: 5243
Last Week: 8869
This Month: 2355
Last Month: 37593
Total: 117035


Partners:

HTML5, CSS3, SVG, tutorials

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:

Statistics:
Search Engine Genie Promotion Widget
Home

Extracting a value with Regular expressions in Java

I wanted to extract an exact value from the given String, in this situation it was a value of the VIEWSTATE input element: In java there are many ways how to work with regular expressions, but it returned me only that the string matched the exact pattern, but not the extracted part of the string I needed. Here's the code that does all the magic:


-------
Pattern pattern = Pattern.compile("name=\"__VIEWSTATE\" value=\"(.*?)\"", Pattern.CASE_INSENSITIVE);
// finds a viewstate value in the string with regular expression

Matcher matcher = pattern.matcher(response);
while (matcher.find()) {
System.out.println("Found a match: " + nameMatcher.group(1));
System.out.println("---");
}
-------

The group(1) element returns the value enclosed by the round brackets. Then you can work with the value itself. Enjoy
 

Add comment


Security code
Refresh

No Tweets

Add URL of a programming website
register as a freelancer
submit your project
open freelance projects you can work on
webmaster resources
write paid blog posts about programming - tips and articles
bugs and features

Recommended: (advertise)
Download Joomlawatch 1.2.12


Green Geeks Hosting -
World's best selling green web hosting


Outsource your project
-
Submit your project description with all the requirements to more than 600 freelancers from around the world for FREE.

Register as a Freelancer -
Submit your project experiences, programming languages and your other skills


Advertise Here
-
Promote your services and get the new customers from the community of webmasters / programmers visiting CodeGravity.com

HostMonster.com -
best cheap Joomla Web hosting. Website joomlawatchdemo.com is hosted by them with domain for $6,95/mo.


Freelancers, create paid articles
-
Looking for freelancers with experiences in Java to write paid articles on their experiences

FastDomain.com -
Fast Domain hosting. Hostmonster alternative. Also for $6.95/month.



News from Twitter:
No Tweets
RSS Feeds:new

rss Freelance
rss Projects
rss Forum
rss Resources

Popular:
MathGuard
download mathguard
Random screenshot:

linoopz15.jpg


Poll

At what price would you purchase JoomlaWatch ad-free license?
 
Privacy policy | Advertise | Donate | Doucovanie Nemcina
Joomla Visitors Google Map
Loading map...
Joomla Visitors Google Map
Visitors Google Map Agent

Locations of visitors to this page


©2003-2010 Codegravity.com