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



Home Answers Viewqa Java-Beginners including index in java regular expression
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Gaurav Singh
including index in java regular expression
0 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners


Hi,

I am using java regular expression to merge using underscore consecutive capatalized words e.g., "New York" (after merging "New_York") or words that has accented characters in between. My pattern works fine if the match is found in the middle of the input string e.g., Near left bank of Rio Amazonas.

but if the string is "On Rio Amazonas" the using my patterns i get result as "OnRioAmazonas". Whant i want to know from you is that is it possible using regular expression to avoid first word in the sentence so that i dont need to worry about first word starting with capital letters in a sentence. I am using following patterns:

if (description.length() > 0) { Pattern p1 = Pattern.compile("\p{Lu}\p{L}+(\s+\p{Lu}\p{L}+)+"); // original pattern Pattern p2 = Pattern.compile("(\p{Lu}\p{L}+)\s+de | das | da | do | dos\s+(\p{Lu}\p{L}+)+");

                Matcher m1 = p1.matcher(description);
                while (m1.find()) {
                    String oldStringG1 = m1.group();
                    String newString = oldStringG1.replaceAll(" ", "_");
                    description = description.replace(oldStringG1, newString);
                    m1 = p1.matcher(description);
                }
                Matcher m2 = p2.matcher(description);
                while (m2.find()) {
                    String oldStringG1 = m2.group();
                    String newString = oldStringG1.replaceAll(" ", "_");
                    description = description.replace(oldStringG1, newString);
                    m2 = p2.matcher(description);
                }
            }

Looking forward for your help...

Thanks YJS


Advertisement
View Answers

Related Tutorials/Questions & Answers:
including index in java regular expression
including index in java regular expression  Hi, I am using java regular expression to merge using underscore consecutive capatalized words e.g.... from you is that is it possible using regular expression to avoid first word
java regular expression
java regular expression  hi i need java expression which allows all characters with minimum 2 characters and maximum 20 characters in answers field after selecting security questions
Advertisements
Regular expression
Regular expression  how i write a regular expression for a pattern which present in between
about regular expression - Java Beginners
about regular expression  Consider the grammar G: S -> ( L ) | a L -> L, S | S a) Eliminate the left-recursion from grammar G. b) Construct a recursive descent parser for G
Regular expression
Regular expression  I have the regular expression : var x=/(^\d+$)/ which allows only numbers. It does not accept character, decimals. However it accepts zero. I want an expression that takes numbers(no decimals)except zero
Finding start and end index of string using Regular expression
Finding start and end index of string using Regular expression... the way for finding start and end index of the string using regular expression... a pattern object and compiling  the given regular expression into a pattern
Regular expression
Regular expression  can some one explain how below regex works, ndmurl1=${ndmurl#${ndmurl
Regular expression
Regular expression  how i extract string Coalition of civil society organizations and CSOs from string:- CSOs : What happening in Yemen is political crisis SANA'A, May 16 (Saba)- Coalition of civil society organizations (CSOs
split string with regular expression
split string with regular expression  How to split string with regular expression in Java
A regular expression contains another regular expression - PHP
A regular expression contains another regular expression   Please explain how it works in PHP... RegEX1 = "a.*b"; RegEx2 = "a1.*b"; Thanks
javascript regular expression
javascript regular expression  i need a regular expression code for JavaScript
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
regular expression for phone number
regular expression for phone number  Hi, i need the regular expression code for phone number in PHP. Thanks.   PHP - regular expression code for phone number \+?([0-9]{2})-?([0-9]{3})-?([0-9]{6,7
using regular expression
using regular expression  How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php
Regular expression in c++{MFC}
Regular expression in c++{MFC}  Hi ALL, I want to build a regular expression in c++{MFC} which validates the URL. The regular expression must... of %5C & %2F character. How can we develop a generic Regular Expression
Regular expression contains character - PHP
Regular expression contains character  A PHP script that can check if the regular expression contains character
Regular Expression for removing XML Tags
Regular Expression for removing XML Tags  Hi, Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified... after applying regular expression is only "How are you".Need to remove all XML
Java validate phone number using regular expression
Java validate phone number using regular expression In this tutorial, you will learn how to validate the phone number using regular expression. The user is allowed to enter a number in a specific range i.e., a number should only
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
Regular expression in PHP for email - PHP
Regular expression in PHP for email  can any one tell me how to write regular expression in PHP for email to retrieve all the valid email ID's from the email
What is regular expression beginning of line ?
What is regular expression beginning of line ?  Hi, I one of my Java... and then replace the text using replaceAll() function of String. What is regular expression... this will be helpful for you. http://www.roseindia.net/java/string-examples/string
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java... did that by using this expression String regex = "Courses\[\'[^\']+\'\]\.Title... seperately... So my final output should look in the form given below and including
PHPMYSQL REGULAR EXPRESSION - WebSevices
PHPMYSQL REGULAR EXPRESSION  Hello all, I have to read a file and insert the match into mysql.File has a follwing lines. user196 Auth-Type := Local, User-Password == mypass@wd Session-Timeout = 3600
Pointing and indicating matcher using regular expression
Pointing and indicating matcher using regular expression... to point the matcher and also indicate the index of the matcher using regular expression. For this we are going to make program named Indicating_Matcher.java.
Regular Expression Search Program
Regular Expression Search Program       Regular Expression: Regular Expression is used to perform many... which finds the character sequences for the regular expression. Matcher
Reset the matcher using regular expression
Reset the matcher using regular expression  ... the String using regular expression. For this we are going to make program named...):- Creating a pattern object and compiles the given regular expression
PHP Regular Expression
PHP regular expression allows programmer to perform various task like... strings. PHP Regular expression also allows you to validate a email, phone... chunks. There are basically two types of PHP Regular Expression. POSIX
regular expression expalanation i need
regular expression expalanation i need  hi......... here is my code could explain it <html> <script language = "Javascript">... your regular expression. ^ shows beginning of string
Regarding regular expression with swing - Swing AWT
Regarding regular expression with swing  Regular Expression for value that should be greater than 0.0 and less than 999.9 0.0 > value < 999.9 Please Check it, in cell editor in JTable to validate a particular
Phone number validation using regular expression
Phone number validation using regular expression  Explain phone number validation using regular expression in JavaScript.   phone = phone.replace(/[^0-9]/g, ''); if(phone.length != 10) { alert("not 10 digits
Advertisements
 

 

 

DMCA.com