Tagged Questions
0
votes
0answers
18 views
Seeking resolution to a baffling Pattern oriented exception being thrown
I'm trying to write a regular expression that checks whether the Path entered by the end-user is accurate or not.
Here's my program:
BufferedReader br = new BufferedReader(new ...
0
votes
1answer
33 views
Can I negate the dot?
The following regular expression matches the character a:
"a"
The following regular expression matches all characters except a:
"[^a]"
The following regular expression matches a ton of ...
0
votes
2answers
13 views
Java Mysql Escape Backslashes for Select
There are a lot of questions already regarding escaping backslashes in java. Depending on what i use i can replace either the char sequence or by regex. however this works fine for escaping one or two ...
1
vote
3answers
44 views
Splitting by java regular expression
I have a string like:
Snt:It was the most widespread day of environmental action in the planet's history
====================
-----------
Snt:Five years ago, I was working for just over minimum wage
...
-2
votes
2answers
33 views
Use regex to replace a specific pattern
From a given string, am trying to replace a pattern such as "sometext.othertext.lasttext" with "lasttext". Is this possible in Java with Regex replace? If yes, how? Thanks in advance.
I tried
...
0
votes
2answers
43 views
Regex getting String in between parenthesis
I am just learning about using Regex and it does seem a bit complicated to me.
I am trying to parse this String in Java:
new Array(new Array('1','Hello'),new Array('2','World (New) Again'),new ...
2
votes
3answers
61 views
Replace everything with spaces except line terminators
Is the following replacement guaranteed to leave the line terminators \r\n intact?
"Hello\r\nWorld".replaceAll(".", " ")
I'm not sure if the DOTALL flag can be globally specified for all regular ...
-1
votes
1answer
35 views
Regex expression for a filename in java
I'm having trouble saving a specific string from a filename using regex. The filename is in this format:
PM_IGZZZZZ_XX_YYYYMMDDHHmm_01.csv
XX can be 5, 15 or 60
ZZZZZ can be any numerical value ...
0
votes
1answer
28 views
Pattern and Matcher regex in Java
I'm having a problem using Pattern and Matcher in Java..
I'm trying to use it to extract two numbers from a String containing at least .SXXEXX. where XX is the int's I want to extract. Any ...
0
votes
1answer
29 views
What is wrong with my regular expression for replacing the content of HREF links in Java?
I'm writing a regular expression to replace all occurrences of the substring ">(Some Text)</A>" with .html">(Some Text)</A>" (case insensitive) in an HTML document.
However, it does ...
0
votes
3answers
42 views
Replace first occurrence of character not in the beginning of a word in a word using regex
Example:
"initial" should return "ineetial", "alumni" should return "alumnee" and "illuminati" should return "illumeenati"
However, using this code:
str = str.replaceAll("(\\w+)i(.?)", "$1ee$2");
...
-1
votes
2answers
27 views
How to check if a word is present in a substring of a string using java Regex
I have a list of strings of the format "The Url is http://m.gap.com/division.html?dn=gd5646"
The output for the program is a list of urls with the word product in it.
I have managed to obtain the urls ...
0
votes
0answers
19 views
JPA: Equivalent for Oracle's REGEXP_SUBSTR
I have following Oracle SQL query:
SELECT SUBSTR(col, 0, INSTR(col, REGEXP_SUBSTR(col, '\.\d+$')) -1) AS col_new, col as col_orig AS col_orig FROM tab;
I have data in table like:
col
ABC.A.01
...
0
votes
2answers
39 views
Using regex in java 1.4
I am trying to write regex to valid a string which should contain
"A - Z", "a - z", "0 - 9", "-" , "_", "/" , "." , "%" , and ":"(period) characters only.
I have written code as below:
import ...
-6
votes
2answers
24 views
find substring using match regex
Using regex how to find a substring in other string. Here are two strings:
String a= "?drug <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/possibleDiseaseTarget> ?disease .";
...
0
votes
3answers
44 views
Java: match all strings that do not end in .htm?"
I'm parsing an HTML file in Java using regular expressions and I want to know how to match for all href="" elements that do not end in a .htm or .html, and, if it matches, capture the content between ...
3
votes
2answers
54 views
Splitting a string without using String.split() - and returning delimiters
String s = "ab#cd#ef#gh#";
String regex = "#";
char [] sChar = s.toCharArray();
char [] regexChar = regex.toCharArray();
int count = 1;
for (int i = 0; i < regexChar.length; i++){
for (int j ...
0
votes
4answers
39 views
java format strings based on a pattern
I have a requirement like this. My code generates random strings and it can be alpha, numeric and alphanumeric ones.
Lets say one of the numeric strings are "7882347812". I want to format this to ...
0
votes
1answer
34 views
Why does this regex not seem to work?
I have string that I want to replace in a file, when I see hostName=some_word I want to replace it with some_other_word but the zero-width negative lookbehind regex I use seems to be failing in the ...
0
votes
1answer
63 views
Regular expression for comma separated string
I am trying to create a pattern in Java that matches the following string;
String message ="%%140911,A,140929100526,S0117.6262E03647.8107,000,067,F100,4F000100,108";
The pattern I have formed is ...
-1
votes
2answers
50 views
Regex to separate hexcode
I have a String like:
String s = "IPhone 5s $400"
Which I want to get as:
String s1 = "IPhone 5s";
String s2 = "$400";
What I tried was getting the last word of the String and ...
0
votes
4answers
60 views
How to check if some words are in a string or not?
What I want to do is checking if some words are in a string or not.
For example, I want to find these name of malls in a string:
"paris van java mall"
"mega mall"
and I want to find that name in a ...
0
votes
1answer
46 views
Return specified number of words before and after given position in text
I have a BIG problem with the following code. I would expect it to return n number of words before and after the found keyword (needle) but it never does.
If I have a text, say
"There is a lot of ...
0
votes
2answers
23 views
Java Regex Replace Namespace
New to Regex.
Can anyone tell me what the java regex replacement code is to replace the following XML
<?xml version="1.0" encoding="iso-8859-1"?><message ...
0
votes
1answer
43 views
Replace spaces in string with regex in Java [duplicate]
I'm trying to replace all all spaces in string with one space. I'm trying this:
String src = "2. Test Sentence with spaces";
String out = src.replaceAll("\\s+", " ");
...
0
votes
3answers
54 views
Java - regular expression fixed length split into array
I've seen an example once before, but cannot find it again on how to split a fixed length data stream into an array using Regular expressions. Is this actually possible, is so, does anyone have a ...
3
votes
4answers
118 views
Regular Expression: Finding n characters with exactly (or at least) one linebreak
I'm having problems designing a regular expression. I'm not even sure if it is possible at all.
I want to match n characters, but one of it has to be a line break (or any defined character).
This is ...
-2
votes
2answers
50 views
Regex for extracting phone numbers
I have following requirements:
Number (in sequence or seperated by hyphen or space)
Can have hyphen - in between [optional]
Can have space in between [optional]
Can have open braces ( and closing ...
0
votes
1answer
46 views
How do I replace illegal characters in a filename?
I am trying to create a zip with folders inside it and I have to sanitize the folder names against any illegal characters. I did some googling around and found this method from ...
0
votes
2answers
45 views
Regular expression 30 numbers + space + hypen + space+ 1 number
I have this code to find this pattern: 201409250200131738007947036000 - 1 ,inside the text
final String patternStr = "(\\d{30} - \\d{1})";
final Pattern p = ...
0
votes
1answer
58 views
Java split() is returning an empty first element
I have a string[] = [5 5, 1 2 N, LMLMLMLMM, 3 3 E, MMRMMRMRRM]
When I split the 2nd and 4th elements. I get
[, L, M, L, M, L, M, L, M, M]
[, M, M, R, M, M, R, M, R, R, M]
import java.io.*;
...
0
votes
3answers
35 views
Replace several html absolute path strings with relative path
I have an html file and several jpgs that I retrieve from a database. This html has several img scr="..." tags and each tag has an absolute path based upon the customer's url. My task is to replace ...
0
votes
3answers
24 views
Java Regex error/issue (what kind of character is [ )?
I am trying to write an array to a text file, and in the process I have noticed that arrays are written in the format of: [1, 1, 2, 2] (an example of an int array) and I want to convert an array, take ...
-1
votes
2answers
38 views
Java Regex - What does each of these parts do?
if(password.matches("(?=.*[0-9].*[0-9])(\\w{8,})") )
System.out.println("Valid Password");
else
System.out.println("Invalid Password");
I am checking a password to ensure it has ...
-1
votes
3answers
29 views
Extracting comma separated values from String coming from HTTP post
I would like extract comma separated values which I am getting from HTML post request.
Example:
****"file"; filename="TEST.csv"
Content-Type: application/vnd.ms-excel
...
-4
votes
0answers
37 views
What is The Regex To Extract Column Names From a Select Query In Java [closed]
i can not understand how regular expressions work. i have studied this tutorial and it seemed so easy!
i need to analyse a select query and find patterns like As "columnName" then extraxt the column ...
-1
votes
3answers
26 views
Regular Expression for Skipping splits in java
Let's say i have a line that looks like this
40 ,O12,O23,O34,O2
There's tab between the 40 and comma ,.
I need a regular expression that outputs
O12,O23,O34,O2
as one String.
...
1
vote
1answer
31 views
make axception word source code using regex
my program should detected method or constructor with source code java.
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
...
-1
votes
3answers
42 views
Replacing all special characters, numbers and alphabets
This is the code for example
String a="abcd ABCD 0123 !@#$%^&*()";
This is syntax for replacing numbers & alphabets with blank
a = a.replaceAll("[a-zA-Z0-9]","");
This is syntax for ...
1
vote
3answers
40 views
java string split regular expression retain delimiter
Give an input string such as
"abbbcaababbbcaaabbca"
I want to split such a string into an array of groups "bca" "ab" "a" and "b"
So the above example would return
"ab", "b", "bca", "ab", "ab", ...
-2
votes
2answers
35 views
Simple java Regex doesn't
When i use this code, i don't have the expected result :
pattern = Pattern.compile("create\\stable\\s(\\w*)\\s\\(", Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher("create table CONTACT ...
2
votes
1answer
33 views
Detecting Japanese characters in Java strings
I am trying to detect if a java string contains Japanese characters. Since it does not matter to me if the characters form a grammatically correct sentence I thought I'd use a regex to match any ...
0
votes
1answer
38 views
Validating Identifier Using Regular Expressions
Hello I am struggling with what to return from my final isValid method I basically need to check if an email address is valid or not please any and all help is appreciated.
public class EmailAddress ...
1
vote
1answer
32 views
Java Regex matching not working with spaces
I want to check the string contains ST=. there may be spaces before/after ST and =.
so i have regex match as "\\s*ST\\s*=\\w+", but it doesn't work. Any thoughts?
String REG_MATCH = ...
-1
votes
2answers
34 views
Regex to parses string containing escape character for URL
I have sample Url that I am trying to read from a file
I have to parse URL which contains an escape character before :
eg https://www.sample.co.in:8080?
or http://www.sample.co.in
Sadly the regex ...
0
votes
2answers
53 views
java regex extract not working?
What am i missing??
This is the 'dataStoreConstructor' I am passing to the method code below -
url='https://www.salesforce.com/services/Soap/u/26.0',corpnet_prodnet='Corpnet'
public void ...
1
vote
5answers
61 views
Regular expression for extracting the city name from string pattern
I wanted to extract the city name from the following example patterns.
Philadelphia.json
Philadelphia
Washington D.C..json
Upstate New York.json
Only one regex. should be suitable for all the ...
0
votes
5answers
44 views
Java Regex - Ignoring size string in image url
I'm trying to remove the size specifications from image URL strings but I can't seem to find a solution. I don't much about regex so I tried [0-9x] but it only removed all numbers in the url rather ...
0
votes
5answers
61 views
Extract text between two tags using Regx
I have a text file in this format:
<seg id="1"> They are the same thing. Let's shoot them both. </seg>
<seg id="1"> We can't wait for you to move back either. </seg>
...
0
votes
3answers
36 views
Add separator in string using regex in Java
I have a string (for example: "foo12"), and I want to add a delimiting character in between the letters and numbers (e.g. "foo|12"). However, I can't seem to figure out what the appropriate code is ...