0
votes
2answers
15 views

RegEx in Java for Email Matching

([a-zA-Z0-9\.]+)\s*(?: at |@|( at ))\s*(\w+)\s*(?:do?t|\.)\s*(\w+)(\s*(?:do?t|\.)\s*(\w+))? I've written the above RegEx to pick up email addresses. This successfully picks up bob at gmail dot come ...
0
votes
2answers
23 views

in java using regex how can i find last 3 words from a position in string

in java using regex how can i find last 3 words from a position in string for example i have an string It is situated near the Bara Imambara and on the connecting road stands an imposing gateway ...
1
vote
1answer
31 views

Extract string between optional brackets

I am trying to extract strings between multiple brackets, but it should also work without any brackets. This is what I've got now Pattern pw = Pattern.compile("\\(?(.*)\\)?\\^\\(?(.*)\\)?"); ...
2
votes
2answers
49 views

Java RegEx for Email Detection

Can someone please advise me as to why the following regex is not picking up the following string: "bob at gmail dot com"? ...
1
vote
1answer
22 views

How to assemble a Regular Expression the includes newlines and stop at particular character sequence?

I am writing some regular expr to extract sentences from text.. My problem is that my expression getting unwanted texts also... For Example : The main Text- 1) ....... ....... Inventors: Peng Ji, ...
0
votes
4answers
24 views

RegEx to match all characters between the last occuring upper case word and another word in a String

I need to match all characters between the last occuring upper case word in a String and another word. Input Text:The CLEVER fox JUMPED OVER the big and (Hole 2) wall in the night. RegEx Used : ...
0
votes
4answers
55 views

Get an array of Strings matching a pattern from a String

I have a long string let's say I like this #computer and I want to buy it from #XXXMall. I know the regular expression pattern is Pattern tagMatcher = Pattern.compile("[#]+[A-Za-z0-9-_]+\\b"); ...
-4
votes
1answer
57 views

Split string using a string, split() function

I have the string "Hello\nIm\nCory!" How can I separate the string into String[] aLore? I have used string.split() using: "\n", "\\n", "\\\n", "\\\\n" All of those with plus' at the end, all ...
1
vote
2answers
39 views

Java Regular Expression - allow only certain characters and digits

I need to write regular expression that allows only digits, characters like & | . ( ) and spaces. import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" ...
0
votes
1answer
28 views

Complete String so that it matches regex

I have a string and a regex like the following: fb f(\w+)=\1 I would like to use these to generate: fb=b Is there any way to do this in Java? I can confirm that fb matches the f(\w+) using ...
0
votes
2answers
31 views

Reverse the string without changing white spaces in java

I'm working on reversing the string word by word and making sure that all the spaces, tabs and white spaces character etc. are not changed or removed. I have tried few solution using Java, but ending ...
0
votes
2answers
53 views

Java Regex Matcher not giving expected result

I have the following code. String _partsPattern = "(.*)((\n\n)|(\n)|(.))"; static final Pattern partsPattern = Pattern.compile(_partsPattern); String text= "PART1: 01/02/03\r\nFindings:no smoking"; ...
3
votes
1answer
62 views

Match a regular expression against an array

We all know how we can use regular expressions to find things in strings. However, regular expressions are not, at least mathematically, limited to just actual Strings and char[]s; one could use a ...
1
vote
3answers
43 views

Angle regex expression

Hi I have the following string in java.. String DEGREE = "\u00b0"; String angle = "\u2220"; String a = "Working 1: " + angle + " ABC = 20" + DEGREE + " + " + "70" + DEGREE + " = 90 "+ ...
2
votes
2answers
48 views

Pattern between two string in java

I have a long string which is of the form: How can i extract the data between <DETAIL> and </TEXT>, note that its NOT an xml file. There is a new line after every ending. I tried the ...
0
votes
0answers
41 views

Pattern not working with less than one argument

Hi I'm trying to setup a hostname pattern for a minecraft-server plugin. It will look through the arguments of the chat message and try to find any possible hostnames. The code works unless the ...
2
votes
3answers
52 views

How to fetch a string between <> in java

I have a URL link Link=<http://mysample.link.com/first/12/sample?page=1234-asdf>;rel="next" I want to fetch everything between <> and get the result as ...
0
votes
2answers
28 views

Regex: Matching comma not followed by a number

I want to extract some groups from command-like strings with the form: foo(bar,1). > need 'foo', 'bar' and '1' foo(bar,1.1). > need 'foo', 'bar' and '1.1' foo(bar-{foo,bar},1.1). > need 'foo', ...
2
votes
3answers
42 views

regex to match text between two closest words

could you help me with regex to match text between two closest words, please? For example: text KEYWORD1 text KEYWORD1 text KEYWORD2 text KEYWORD2 The result must be: KEYWORD1 text KEYWORD2 ...
0
votes
1answer
59 views

Java: Replace all matching substrings of a string with their hashes

I would like to replace all matching substrings of a string with a hashing of them. Lets say I have a string like this String myString = "This is a A1B4F string with some 342BF matches FFABC that ...
0
votes
4answers
51 views

using regular expression in java

I am new to regular expressions. I am using java regular expressions to match the following cases: - DOC_BS [\bDOC_[A-Z]+] and it works fine - DOC_BS1 How can i match both of the above statements ...
0
votes
2answers
69 views

Split line in words and remove String & Numeric words in Java Regex

How to split a line in words and remove String & Numeric words by using Java Regex. Here Input is what I receive and Output is what I want: Input: 05 ECPRF-057 PIC S9(4) VALUE +0057 COMP-3. ...
-2
votes
1answer
42 views

The difference of Regex between js and java

I have the following Regex to test for mobile numbers: /^1[0-9]{10}|[0-9]{8}$/. If I have the String "123456789", I test it in Java, and result is false; but in JavaScript, the result is true. Can ...
1
vote
4answers
64 views

What is the regex for checking string A for the presence of any 3 consecutive characters in string B?

For example: I have a username string: "[email protected]" I want to search some password string to make sure it doesn't contain any 3 consecutive letters in the username, e.g.: no "joh", ...
2
votes
1answer
28 views

Removing consecutive occurreneces of certain letters

Hey I am trying to remove any consecutive occurrences certain but not all letters, can anyone see what I am doing wrong please? result2 = result2.replaceAll("[aeioucgjkqsxyzbfpvwdtmn]\\1+", "$1"); ...
4
votes
1answer
70 views

why this regex is not working on java 7?

As per answer from How to determine whether a character is a letter in Java? i was using below code snippet to match if string contains unicode letter or not in the begining. It was working great on ...
1
vote
2answers
34 views

ignore any non-alphabetic characters and capital letters from a string

prob a silly question but here goes: I am looking to ignore any non-alphabetic characters and also capital letters from a string. if (names[j].matches("[a-zA-Z]+")){ ...
1
vote
0answers
29 views

IS it possible to regex search text in a PDF document OR Word document using java?

I want to search text from a word document or pdf document using Regular Expression from Java . IS it possible ? How to do this ? for example the PDF /DOC look like this: (54) About Keyboard ...
0
votes
2answers
31 views

Regexp returns blank when only containing letters

I have a regex expression ^[0-9]{6}[A-Zööö|0-9]{1}[0-9]{3}$ when the first characters are letters the field becomes empty. I want it the preserve the letters. The following is the form ...
0
votes
4answers
58 views

searching for multiple occurrences of variables in a method

I have a problem with cursor leakage in my Java project. Typical example: private void doSomething() throws Exception { String sql1= "some sql statement"; String sql2= "some other sql ...
0
votes
2answers
30 views

Replace regex characters

I want to replace the substring \\d+-\\d+ to a random genarated number in this String <!-- This is Siebel Order identified --> <tns:id> <tns:idValue>\\d+-\\d+</tns:idValue. I am ...
3
votes
1answer
31 views

Looking to replace a pattern of one string with a string that uses info from the pattern found?

It's tough for me to explain this problem without this example: I'm looking to replace every instance of the string "switch('Pujols','Albert')" with the string "Albert Pujols", or the string ...
0
votes
3answers
60 views

Java regex with tags

I am trying to create a regex to match some text from an XML document and then replace the numbers within the text with randomly generated numbers (8 digits). Specifically, below is the text that I ...
1
vote
5answers
51 views

RegEx to find the word between last Upper Case word and another word

My problem is to find a word between two words. Out of these two words one is an all UPPER CASE word which can be anything and the other word is "is". I tried out few regexes but none are helping me. ...
-1
votes
1answer
36 views

How to validate password using annotation on bean

Hi i want to validate my password using annotation but its not working please check @Pattern(regexp = "([0-9])([a-z])([A-Z])", message = "password does not meet the required criteria") please ...
1
vote
2answers
48 views

Java string.match / string.replace does not match regex correctly

I have a string "123.0" and use "123.0".matches( "(\\.)?0*$" ) to check if it has any trailing zeros but it does not match. The same regexp matches string correctly @ http://regexpal.com/ How about ...
1
vote
2answers
53 views

How to locate the end of the line in regex?

I have the following regex in = in.replaceAll(" d+\n", ""); I wanted to use it to get rid of the "d" at the end of lines But I just won't do that d <i>I just won't do that</i> d No, ...
0
votes
1answer
29 views

Java/android - check if string `FileName` contains any file-name-disallowed characters

I am checking if a string filename is safe for saving by checking if it has any strange characters with a Regular expression. It is will be a .json file and should also allow spaces in the file name. ...
1
vote
2answers
44 views

How to get rid of numbers in the String?

I have a very long String. I need to get rid of numbers there And we're never gonna bust out of our cocoons 65 00:03:04,113 --> 00:03:06,815 - if we don't put our busts out there. - Nice ...
0
votes
3answers
45 views

Regex that doesn't match character declarations

So I'm trying to come up with a regex that will match things like: ( ) , ; { } . but not '(' ')' ',' ';' etc... but I am really struggling. Here's what I've got: private String symbolMatcher = ...
0
votes
2answers
65 views

RegExp for whitespaces without tabs

I am trying to build a parser for a sonar-plugin where the tokens can contain spaces and tabs in order to use them for implementing a checking rule for spaces. Therefore, I want to store them to ...
1
vote
1answer
54 views

How to extract sub-strings for a collection of text?

I extracted text from pdf document. .. I want to extract some particular fields in it using java.. The portion of text .. US00RE44697E (i9) United States (12) Reissued Patent (10) Patent ...
0
votes
3answers
50 views

Non-greedy match does not work

I have a string like this <tag1> <tag1> any text </tag1> text </tag1>and i want to find a <tag1>, that contains shortest text in this string. I used ...
0
votes
2answers
25 views

use of buffer object at appendReplaccement () method of Matcher class

public Matcher appendReplacement(StringBuffer sb, String replacement) Here why appenedReplacement() method should use Buffer object and why we don't use input string instead off it?
-1
votes
0answers
49 views

regex for subdomain name not working

I modified this after finding a regex for subdomains that was not completely working but this still doesn't cover the case of abc123 which is valid ^[a-zA-Z]+([-_][a-zA-Z\\d]+)*$ I am passing this ...
5
votes
2answers
104 views

Replace decimals 1 to 10 with name (“one”, “two”..)

I was trying to take a string and then returns a string with the numbers 1 to 10 replaced with the word for those numbers. For example: I won 7 of the 10 games and received 30 dollars. should ...
0
votes
2answers
53 views

Java Check string has only certain words and characters

I'm trying to verify that a String only contains certain words and characters. I'm going to receive a string, and need to check that it only contains the following: "(" ")" " AND " Note the spaces ...
0
votes
0answers
25 views

get a substring with regex [duplicate]

how can I get the string form <a to the first > or instead of it, how can I get value of href? I tried it but it's get from open a to close span String str = "<span class=\"foo\"><a ...
2
votes
2answers
50 views

Replace multiple words in a string ln java like php str_replace

I need to find a similar slick way in java to do multi string replace the same way you can do this in php with str_replace. I want to take a string and then returns a string with the numbers 1 to ...
0
votes
1answer
30 views

Data Structure required to store extracted POS tag text in Java

Friends I am doing Sentiment analysis using AANV(adjective-adverb-noun-verb) approach as a my BE final year project. In this project I have done upto the POS tagging, I am using stanford POS Tagger ...

15 30 50 per page