I'm trying to parse the configuration files usually found in /etc/default using java and regular expressions. So far this is the code I have iterating over every line on each file:
// remove comments from the line
int hash = line.indexOf("#");
if (hash >= 0) {
line = line.substring(0, hash);
}
// create the patterns
Pattern double...
Basically I've recently added the below rule in my httpd.conf for ISAPI rewrite on an IIS server to make sure that it always defaults to lower-case file and directory names.
RewriteRule ^(.*[A-Z].*)$ $1 [CL,R=301,L]
This is all fine and dandy for every part of the site except for one directory which we can call /MisbehavingDir, the cod...
I have files having content like
/**
* Some Content
* @param ..
* @author ..
*
*/
function a_sample_function ( $args = '' ) {
I need to extract the text
Some Content
@param ..
@author ..
given a function name a_sample_function ( the * can be removed by a gsub later I believe)
I'm writing this in ruby.
...
I get this behavior in both Chrome (Developer Tools) and Firefox (Firebug). Note the regex test returns alternating true/false values:
> var re = /.*?\bbl.*\bgr.*/gi;
undefined
> re
/.*?\\bbl.*\\bgr.*/gi
> re.test("Blue-Green");
true
> re.test("Blue-Green");
false
> re.test("Blue-Green");
true
> re.test("Blue-Green");
false
However, t...
I'd like to remove all invalid UTF-8 characters from a string in JavaScript.
I've tried using the approach described here (link removed) and came up with the JavaScript:
strTest = strTest.replace(/([\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3})|./g, "$1");
It seems that the UTF-8 validation...
Hello,
I have this kinda template text :
Hello {#Name#},
Thanks for coming blah on {#Date#} and
we love to see you again here with
{#President#}
So I am trying to get {#...#} templates parts and put them into an array.
But my expression didn't work :
\b(?<=\{\#)(.*)(?=\#\})\b
The result became something like this for...
I am using VB .NET to write a program that will get the words from a suplied text file and count how many times each word appears. I am using this regular expression:-
parser As New Regex("\w+")
It gives me almost 100% correct words. Except when I have words like
"Ms Word App file name is word.exe." or "is this a c# statment If(a...
Okay, I have the following PHP code to extract an email address of the following two forms:
Random Stranger <[email protected]>
[email protected]
Here is the PHP code:
// The first example
$sender = "Random Stranger <[email protected]>";
$pattern = '/([\w_-]*@[\w-\.]*)|.*<([\w_-]*@[\w-\.]*)>/';
preg_match($pattern,$sender,$matches,PRE...
Hi ,
I spent lot time figuring out a simple regex to return a group (only 1st group).
So the string can be -
"No purchase required" or "Purchase of $50.00 worth groceries is required."
I am trying to write a regex which can parse "No" or "50" based on the given string.
This is what I have written.
(?:(No) monthly maintenance|Purchas...
My XML is mal-formated for tag. Specifically, I want every tag that is not ended with to be corrected. How do I match such pattern and using ReplaceAll to do that?
Pattern r = "<img.*?[^/]>" // sth like that?
...
I want to write a jQuery function that will return only a part of a given text. For example, in the text:
http://somesubdomain.somesite.com/
How can I write a function so that it returns the text "somesubdomain"? In other words, I want to "subtract" the text "http://" and ".somesite.com/".
Thanks in advance
...
I want to verify that the HTML tags present in a source string are also present in a target string.
For example:
>> source = '<em>Hello</em><label>What's your name</label>'
>> verify_target(’<em>Hi</em><label>My name is Jim</label>')
True
>> verify_target('<label>My name is Jim</label><em>Hi</em>')
True
>> verify_target('<em>Hi<label>M...
Hi All,
I'm trying to use windows' API IsTextUnicode to check if a character input is unicode or not, but is sort of buggy. I figured, it might be better using a regex. However, I'm new to constructing regular expressions. What would be the regex to check if a character is unicode or not?
Thanks...
...
I am not very good at regular expression but want to do some thing like this :
string="c test123 d split"
I want to split the word based on "c" and "d". this can be any word which i already have. The string will be given by the user. i want "test123" and "split" as my output. and there can be any number of words i.e "c test123 d split ...
Amazon "s3cmd ls" takes like this output:
2010-02-20 21:01 1458414588 s3://file1.tgz.00
2010-02-20 21:10 1458414527 s3://file1.tgz.01
2010-02-20 22:01 1458414588 s3://file2.tgz.00
2010-02-20 23:10 1458414527 s3://file2.tgz.01
2010-02-20 23:20 1458414588 s3://file2.tgz.02
How to select all files of archive, ending at 00 ... XX...
I want a regex to find the following types of strings:
http://anything.abc.tld
http://anything.abc.tld/
where
abc -> abc always remains abc
anything -> it could be any string
tld -> it could be any tld (top-level-domain) like .com .net .co.in .co.uk etc.
Note: The url must not contain any other thing at the end, means http://a...
So the user may search for "10 mbit" after which I want to capture the "10" so I can use it in a speed-search rather than a string-search. This isn't a problem, the below regexp does this fine:
if (preg_match("/(\d+)\smbit/", $string)){ ... }
But, the user may search for something like "10/10 mbit" or "10-100 mbit". I don't want to ma...
Visual Studio Find and Replace Regular Expressions
Find lines with quoted strings, not containing strings include or trace
i am tryling to find out all lines in c++ project that contains some text
as i have to use visual studio, i have to use its Find and Replace
http://www.codinghorror.com/blog/2006/07/the-visual-studio-ide-and-regu...
I'm currently using regular expressions to search through RSS feeds to find if certain words and phrases are mentioned, and would then like to extract the text on either side of the match as well. For example:
String = "This is an example sentence, it is for demonstration only"
re.search("is", String)
I'd like to know where the is was...
I have been looking for an answer for a few hours now, so sorry if this was asked a ton of times, I missed it.
I basically want to make a rewrite to ignore the first directory. That first dir in the path will be different so I thought I could use a regex. But my regex is matching all the way to the file name:
RewriteRule ^([a-z]+)?/(.+...