Tagged Questions
0
votes
1answer
12 views
Regex “inter” text
I am trying create a properly regex to validate some values, I will explain next:
I have to validate this lines with he :
$_globalVariables/ns:GlobalVariables/VARIABLENAME/ESB/System
...
1
vote
1answer
14 views
Split String by XML tags in Java
I want to write a method in Java that splits a String by XML tags like follows:
"Lorem ipsum <b>dolor</b> sit amet consetetur <b>diam</b> nonumy."
Should return the Array:
...
-1
votes
2answers
19 views
not detecting number of whitespaces
I have been trying to enable inputs to accept any number of whitelines after the ")" bracket. I have looked up regex websites and "\s+" should do the job, but in my example it doesn't work.
Here's ...
0
votes
0answers
13 views
java.net.MalformedURLException:Fetching data from links embedded in a website using apache nutch
Hi guys I am using apache nutch to extract data. I am able to extract data from a website like so:
:-http://www.truelocal.com.au/
but can we fetch data for specific links from the websites?
:- ...
0
votes
2answers
51 views
How to catch the regex in java
I have a string like below:
"This is the code: cd001, cd002, cd003 "
(i already catch: cd001, cd002, cd003)
but it's must ignore for: cd001, cd002, cd003 in the string below
"This is the code: ...
0
votes
4answers
35 views
First and second tocen regex
How could I get the first and the second text in "" from the string?
I could do it with indexOf but this is really boring ((
For example I have a String for parse like: ...
1
vote
2answers
31 views
Validate each line using a single regex
I am writing an application in Java that is supposed to communicate to an external device. The device responds using the following format
01 02 05 0A 2D 3E
01 02 12 2B 09 07
As a response I may get ...
0
votes
2answers
45 views
Splitting a string based on Pattern Java
Hi I have log files of the following pattern-
2014-03-06 03:21:45,432 ERROR [mfs:pool-3-thread-19] dispatcher.StatusNotification - Error processing notification. Operation aborted.
...
0
votes
2answers
30 views
How to match strings with matching group to extract values?
I have source string "This is my test string" and would like to extract a value of it using a specific pattern: "{0} is my {1} string"
I'd like to extract eg This and test here. How do I write that ...
0
votes
2answers
20 views
java regex to match multiple new line characters up to character
I have the following text string, consisting of a block of text followed by two or more
new line characters (\n maybe \r) followed by another block of text,etc like this
multiple line text
(two or ...
0
votes
1answer
36 views
Java Regex to look for files in multiple directories
I am trying to look for files with ".js", ".less", ".jsp", and ".png" files while also checking for them in many different directories for example "/MyProject/public/someSecurePage.jsp", ...
1
vote
2answers
31 views
Java Split String Regex
Here is a String, I want to split the string such that the symbols and "words" are separate. For example:
String s = "/xyz/abc[bcd(text(),\"string\")]";
I want to have a String array like
...
1
vote
4answers
27 views
why string.matches[“+-*/”] will report the pattern exception?
I have this code:
public static void main(String[] args) {
String et1 = "test";
String et2 = "test";
et1.matches("[-+*/]"); //works fine
et2.matches("[+-*/]"); ...
0
votes
4answers
27 views
Java replace New Lines, Commas, and Spaces at end of String
I am using
mString.replaceAll("[\n,\\s]$", "");
Not working, what is the correct way to remove newlines commas or spaces from the end of a string if the can appear in any order.
0
votes
3answers
48 views
Java Regex matching with parenthesis
I am trying to come up with the regex to find strings matching the following pattern:
(someNumber - someNumber) With the parenthesis included.
I tried:
"\\([1-9]*-[1-9]*\\)"
but that doesn't seem ...
0
votes
0answers
18 views
Matching part of speech sequences in java [on hold]
I'm trying to extract all sequences of [adjective][noun] and [adjective][noun][noun] from a text document. I have tagged each word with its part of speech using Stanford CoreNLP, which lets you loop ...
0
votes
4answers
41 views
Checking if JTextField contains only specific allowed characters
I have a JFormattedTextField where I want only alphanumeric characters to be inserted. I am trying to use this code to launch a JDialog when the user types a non-allowed character, and in case ...
5
votes
5answers
113 views
Java string replacing
I have a string like that ($ character is always surrounded with other characters):
a$b
c$d
e$f
I want my string method to put a \ in front of $ and remove newlines:
a\$bc\$de\$f
I tried this ...
0
votes
2answers
37 views
How to Convert the delimitter in the following string [duplicate]
String str = "1000458551||A210171046D86F9F6EE21B66FE9B1441E20EC1DEF9654A2D092162591C01D26F||1||7707||0||0||1002||1373569142000||HTC One||val||4.1.2||0||1.01.20130206.15441";
str.replaceAll("(|\\|)", ...
2
votes
2answers
31 views
How to make regex matching group excluding the matching characters?
I'd like to match/extract the word test in the string asd{test}asd.
My Regex: ({test}.*) would match {test}. How do I:
- match anything inside the brakets?
- exclude the brakets from the matching ...
0
votes
1answer
44 views
Intelligent String Parsing in java
I have an email Subject line that i need to parse. I need to find first occurance of any word given in a list of words and get the next word which can be separated by
('=' or ',' or ';' or 'blank' or ...
1
vote
1answer
25 views
How to split a string for regex containing lookbehind and lookahead
I want to split the following string:
"VALUE:VALUE,VALUE:[VALUE1,VALUE2,VALUE3],VALUE:VALUE"
into
"VALUE:VALUE"
"VALUE:[VALUE1,VALUE2,VALUE3]"
"VALUE:VALUE"
I expected:
String[] elements = ...
0
votes
1answer
44 views
Fetching strings from a .java file using Regex
I working on making a Regex pattern where I can extract strings starting with ' " ' and ending with ' " '. But here is the problem - a String may also contains a ' " ' with escape character like this ...
1
vote
1answer
29 views
Java RegEx match string containing non-ASCII that exceeds given length
How do I determine if the string contains non-ASCII AND exceeds 5 characters using RegEx?
I tried this pattern: (?=\P{ASCII})(?=^.{6,}$)
I thought (?=) means (?=must be this)(?=and this too).
Given ...
-1
votes
0answers
32 views
how to write java regex pattern for this scenario?
I'm trying to write a pattern which will suffice these below conditions:
1) at least 8 characters
2) won't have special characters
3) will have at least 2 number characters
4) won't contain more ...
1
vote
3answers
46 views
Extract a number from an amount from a String
I have below method which I use to extract amount from a string.
strAmountString = "$272.94/mo for 24 months Regular Price -$336.9"
public static String fnAmountFromString(String strAmountString) {
...
-1
votes
1answer
33 views
how to create regex for password validation
It is at least 7 characters and any one of (number OR capital case OR special character) should be there.
Requirment is:
1) Password must be at least of 7 characters
2) It should contain any one of ...
1
vote
3answers
40 views
How to split a character without removing it (regex) [duplicate]
I want to split a string at a certain point, but keep the character I'm splitting it at. For example:
Input:
a:b
Output:
a
:
b
Is there anyway I can use this with Java's split() method?
Thanks :)
2
votes
1answer
61 views
Very slow look-behind
I'm trying to recover two positions using java regex
The first one is given by the regex:
val r="""(?=(?<=[ ]|^)[^ ]{1,21474836}(?=[ ]|$)(?<=[^A-Z]|^)[A-Z]{1,21474836}(?=[^A-Z]|$))"""
The ...
2
votes
2answers
40 views
Deal with apostrophe in java regex in replaceALL
Trying the replace only the EXACT & WHOLE OCCURRENCES of pattern using the following code. Apparently you in you'll is being replaced as @@@'ll. But what I want is only you to be replaced.
...
0
votes
3answers
32 views
java regex - matching part of string stored in variable
I need to extract up to the directory a file is in, in the folder path. To do so, I created a simple regex. Here is an example path \\myvdi\Prod\2014\10\LTCG\LTCG_v2306_03_07_2014_1226.pfd
The regex ...
-1
votes
1answer
24 views
How to use recursion in python to parse method body from java code?
I have a java code and i need to parse it in python.I am using regex in python for this purpose. I was successfully able to find method names , but to find method body i need to write regular ...
0
votes
2answers
38 views
Identifying capital letters in a string and the position
So i have a string H
and I want to scan the string and check if the letter at a point is Capital and if it is: store the position of that capital letter in an array.
I believe Regex is the tool I ...
1
vote
4answers
40 views
Java how to use pattern matcher using regular expressions to find certain string
I am not familiar with Patterns & matchers, and I am pretty stuck with this problem.
I have a string that I would like to manipulate in Java.
I understand that I have to use
Pattern p = ...
2
votes
3answers
44 views
Need help understanding unexpected output from Java regular expression
package com.j;
public class Program {
public static void main(String[] args) {
System.out.println(Puzzel.class.getName().replaceAll(".", "/")
+ ".class");
...
-1
votes
2answers
32 views
Is ther any regex for replacing below data [on hold]
I want to find tag containing & and replace it with CDATA with regex. I can not parse it with any parser so that it will throw parse exception cause of &. is there any regex for this?
...
1
vote
1answer
35 views
Extracting url by specifying a keyword
I want to extract url of a facebook page by giving a keyword. Eg if I specify a keyword like "gulab jamun" on facebook can I get the url of that page.I tried different ways but I don't even know that ...
1
vote
1answer
36 views
Replace backslash with forward slash
I have the following path:
com/teama/merc/test/resTest
And I want to convert it to this:
com\teama\merc\test\resTest
I am trying to append the above path to this path:
...
-2
votes
3answers
51 views
How to parse a String which has lot of whitespaces?
I am working on a project in which I need to parse a String in which each key: value pair is separated by whitespace.
Below is my code -
RestTemplate restTemplate = new RestTemplate();
String ...
0
votes
3answers
30 views
scanner.useDelimiter() regex java
I have a String in an inconvenient format. Here is an example:
(Air Fresheners,17)->(Chocolate Chips,14)->(Juice-Frozen,24)
I need to go through this String and extract only the first items in ...
0
votes
1answer
40 views
java regex for finding number then text not number then underscore
I need to do a string.indexOf(text) on a text string to search for the pattern
1. some text or
2. some other text or
3. some yet another text, etc
(a number, a dot and some text)
such that I ...
0
votes
1answer
31 views
How to Detect All Redundant Typing (Diamond Operators) With Regex?
I use Intellij IDEA for my Java projects. I want to upgrade my code from Java 6 to Java 7 style (I will not support Java 6 anymore). I want to start with "only" removing redundant typing operators. I ...
1
vote
1answer
35 views
Searching URL within the string
I have following function
private static String changeUrl(String text) {
String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]";
...
3
votes
1answer
38 views
Splitting string into n-length elements for an array
How would I split a string into equal parts using String.split() provided the string is full of numbers? For the sake of example, each part in the below is of size 5.
"123" would be split into "123"
...
1
vote
1answer
56 views
Need help to create regular expression in Java
I will be very thankful if someone will help me to create regex to find all * and **entries in String. Because I have no more idea how to build this regex. In string we can have only * and .
For ...
0
votes
3answers
43 views
How to find different occurrences of a substring in a string using regex?
Basically what I want to do is this:
String mystr = "hello Benjamin Benny Benn hey hey";
String pattern = "Be";
Desired list = {"Benjamin","Benny","Benn"};
I know how to do this in a really simple ...
0
votes
1answer
23 views
Is there a regex for a row of numbers in java?
I am trying to create an if statement that checks a string for illegal arguments
String numbers;
try {
if (numbers.matches("0|1|2|3|4")) {
}
else {
throw ...
0
votes
2answers
19 views
Block SQL Injection entry in a jtextfield using regex
Is any other way to block sql injection in a textfield using regex?
This is what I use to block some special characters:
private static final String PATTERN =
"([^A-Za-z0-9.,'\"% _-]+)";
...
0
votes
1answer
57 views
How to make non-greedy regular expression? “?” does not seem to work
Here is the content of html:
<span style=\"color:red;\">\u7eaa\u51ef\u5a77<\/span>\uff0c\u6709\u6700<span style=\"color:red;\">
and I try to match the first <span ...
1
vote
1answer
59 views
Using a regular expression to find a repeating pattern in Java
I am working in a regular expresion to match with the following string.
String sample1 = "key:value|key:value|key:value|key:value";
As you can see key:value is periodically repeating and the only ...