The following code works:
String str= "test with foo hoo";
Pattern pattern = Pattern.compile("foo");
Matcher matcher = pattern.matcher(str);
if(matcher.find()) { ... }
But this example does not:
if(Pattern.matches("foo", str)) { ... }
And neither this version:
if(str.matches("foo")) { ... }
In the real code, str is a chunk of t...
I will have a different type of string(string will not have fixed format,they will be different every time) from them I want to remove some specific substring.Like the string can be
OPTIDX 26FEB2009 NIFTY CE 2500
OPTIDX NIFTY 30 Jul 2009 4600.00 PE
OPTSTK ICICIBANK 30 Jul 2009 700.00 PA
I want to extract Rs.(digit) from those string a...
I am trying to create a map by taking the first character of each word and it's position in a sentence/paragraph.
I am using regex pattern to achieve this.
Regex is a costly operation.
Are there are any ways to achieve this?
Regex way:
public static void getFirstChar(String paragraph) {
Pattern pattern = Pattern.compile("(?<=\\b)[a...
I need to get list of files on some drive with paths that matches specific pattern, for example FA\d\d\d\d.xml where \d is digit (0,1,2..9). So files can have names like FA5423.xml.
What is the most efficient name to do this?
...
I have a version number with 3 digits as a String,
var version = "1.2.3";
and would like to compare it to another version. To see if version is newer than otherversion,
var otherVersion = "1.2.4";
How would you do it?
...
hi,
I am trying to use a regular expression validation to check for only decimal values or numeric values. But user enters numeric value, it don't be first digit "0"
How do I do that?
...
I have a XSD simple type that should match UUIDs:
<simpleType name="UuidT">
<restriction base="string">
<pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" />
</restriction>
</simpleType>
It correctly matches the following content:
<!-- valid -->
<Uuid>12345678-1234-5678-9012-123456789012</Uu...
Jmeter is not extracting correctly the value with the reg ex.
When I play with this reg ex (NAME="token" \s value="([^"]+?)") in reg ex coach with the following html everything work fine but when adding the reg with a reg ex extrator to the request he doesn't found the value even if it's the same html in output.
<HTML>< script type="te...
Hey, long story short I have inherited some terrible code. As a result a string comparison is buggy when comparing dates due to the format of the date. I am trying to convert the date to a valid DateFormat syntax so I can run a proper comparison.
These are some samples of the current format:
12/01/10 at 8:00PM
12/31/10 at 12:00PM
12/...
Hello,
how could I remove all characters from a string that aren't a-z/A-Z and 0-9 and _ with PHP?
I tried that but it has no effect, it returns the same string back:
preg_replace('[^a-zA-Z0-9_]', '', 'Testdo123_-:=)§%&');
...
I need to check if entire given input matches given pattern.
But wrapping a pattern in ^/$ feels like a hack.
Is there a shortcut for:
var match = Regex.Match(myInput, "^" + myPattern + "$");
?
...
What are the (full) valid / allowed charset characters for CSS identifiers id and class?
Is there a regular expression that I can use to validate against? Is it browser agnostic?
...
I need t check every line of a file for the following pattern:
- 14 Values seperated by an irregular number of spaces.
- Values may be negative (-), decimal seperator is a dot followed by maximum one digit
- The line ends with several spaces
here is an example line:
10015 20100501 1 4.6 6.4 8.4 10.5 86.6 4.0 13.0 ...
Hi,
I'm wondering how facebook extracts the right picture of the article from a link? they ignore any icons, ads images, or other not related images, & they gives you the right image?
What technique/method they use? because i've tried to extract all images using a php regex but how to find the right one?
Thanks
...
I have a following string that I would like to parse into either a List or a String[].
(Test)(Testing (Value))
End result should be Test and Testing (Value)
...
Suppose I have this:
My---sun--is------very-big---.
I want to replace all multiple hyphens with just one hyphen.
...
hello i have the next regex
Dim origen As String = " /c /p:""c:\mis doc umentos\mis imagenes construida\archivo.txt"" /cid:45 423 /z:65 /a:23 /m:39 /t:45rt "
Dim str As String = "(^|\s)/p:""\w:(\\(\w+[\s]*\w+)+)+\\\w+.\w+""(\s|$)"
Dim ar As Integer
Dim getfile As New Regex(str)
Dim mgetfile As MatchCollection = getfile.Matches(o...
Hey I'm a total n00b at Regular Expressions. I'm wondering if this is the best way to match a string that starts with a private IP address (Perl-style Regex):
(^127\.0\.0\.1)|(^192\.168)|(^10\.)|(^172\.1[6-9])|(^172\.2[0-9])|(^172\.3[0-1])
Thanks much!
...
How can I parse a strings like :
name1="val1" name2="val2" name3="val3"
I cannot use split(\s+) as it can be name = "val 1".
I am doing java but any laguage is okay.
...
I have a string called 'raw'. I am trying to parse it in ruby in the following way:
raw = "HbA1C ranging 8.0—10.0%"
raw.scan /\d*\.?\d+[ ]*(-+|\342\200\224)[ ]*\d*\.?\d+/
The output from the above is []. I think it should be: ["8.0—10.0"].
Does anyone have any insight into what is wrong with the above regex statement?
Note: \342...