Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Grouping strings
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Barry
Grouping strings
1 Answer(s)      5 years and 11 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 14, 2008 at 1:05 AM


Hi friend,


import java.util.regex.*;
import java.io.*;

public class StringGroupDemo{
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter text for finding groups of text: ");
String inputStr = in.readLine();
String patternStr = "(a(b*))+(c*)";

// Compile and use regular expression
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
boolean matchFound = matcher.find();

if(matchFound){
// Get all groups for this match
for(int i=0; i<=matcher.groupCount(); i++){
String groupStr = matcher.group(i);
System.out.println(groupStr);
}
}
}
}

-------------------------------

Thanks.


Related Tutorials/Questions & Answers:
Grouping strings - Java Beginners
Grouping strings  I have written a code to determine the lengths of strings. What I need to do is to group strings that are within a certain range, say 15 to 20, 21 to 30, etc. Is there any one out there with an idea?  
Grouping Textboxes
Grouping Textboxes  How to Group the Textboxes in Java
Advertisements
strings
strings  difference between the strings in java and c
strings
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2... is an example which accept two strings as command line arguments and perform
Strings
will contain strings which is separated by ",". From the main method invoke
strings
strings   read sentence and convert all the word into capital case like camelcase   Hi Friend, Try the following code: import java.util.*; class ConvertWordsIntoUpperCase { public static String toCamelCase(String
grouping similar data of array
grouping similar data of array   I have sorted array of integer . how can I define new arrays with similar data . indeed I want to grouping similar data of array . example: input : int num[] = {20,21,21,24,26,26,26,30}; output
Grouping Of Test cases by using struts
Grouping Of Test cases by using struts  Hi, I can able to create, save, delete and execute test cases in my application. But i want to group those test cases. Give me the flow for coding
JPA Grouping
JPA Grouping       In this section, you will learn about the JPA Grouping and how to use it in your... columns. JPA Grouping: Query query=em.createQuery("SELECT
Ideas for grouping the test cases by using struts.
Ideas for grouping the test cases by using struts.  I want to do grouping of test cases by using struts in eclipse. I want to include the action class for grouping the test case. Kindly help me by giving some ideas. Thanks
Hibernate Criteria Grouping Example
Hibernate Criteria Grouping Example In this tutorial you will learn about the Hibernate Criteria Projection Grouping. As we were using a 'group by' clause explicitly in HQL for grouping, there is no need to use this clause
Strings in PHP
Strings in PHP  Hi, I am beginners and want to know about strings in PHP and different ways to print a string. Can someone help me in this regards?   Following tutorials will help you in details about strings in PHP
strings concatnation
strings concatnation  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic
strings in java
strings in java  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1
strings 20june
strings 20june  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
Hibernate Criteria Projections, Aggregation and Grouping
Hibernate Criteria Projections, Aggregation and Grouping In this tutorial you will learn about the Projections, Aggregation and Grouping in Criteria Query... Grouping tutorial Example An example is being given below that will demonstrate
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
split strings in php
split strings in php  how can i split strings in word pair in PHP
compare two strings in java
compare two strings in java  How to compare two strings in java...) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
To check the Rotational Strings are Equall or not
To check the Rotational Strings are Equall or not  I attended 3dplm software company interview....there asked one question related to Strings.The question is................. Write a program to check the given two strings
Advertisements
 

 

 

DMCA.com