I am writing a program in C# that compares strings similarly to the way that Google searches documents for keywords.
I am wanting a search for "stack overflow" to return true for "stack overflow" (plain), "This is the stack overflow." (in the middle), "Welcome to Stack Overflow." (case insensitive), "I like stack overflow." (variable w...
if I have 2 strings like:
a = "hello"
b = "olhel"
I want to use a regular expression (or something else?) to see if the two strings contain the same letters. In my example a would = b because they have the same letters. How can this be achieved?
...
Hi all,
I wanna validate date which can be either in short date format or long date format.
eg: for some of the valid date.
12/05/2010 , 12/05/10 , 12-05-10, 12-05-2010
var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
var valid = (reLong.test(entry)) || (reShort.test(entry));
if(valid...
var dateRegex = /\/Date\((\d+)\)\//g; // [0-9] instead of \d does not help.
dateRegex.test("/Date(1286443710000)/"); // true
dateRegex.test("/Date(1286445750000)/"); // false
Both Chrome and Firefox JavaScript consoles confirm. What the hell, guys?
Edit: even simpler test case:
var dateRegex = /Date\(([0-9]+)\)/g;
dateRegex.test("...
Hi
I have an application with a large number of #if debug blocks which kind of look like the the one below:
#if DEBUG
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("oldXml: " + oldXml.OuterXml);
Logging.Log("XmlDiff: " + diff_sb.ToString());
...
Dear All,
I have a String template from which I need to get the list of #elseif blocks. For example the first #elseif block will be from
#elseif ( $variable2 )Some sample text after 1st ElseIf.
,second #elseif block is from #elseif($variable2)This text can be repeated many times until do while is called. SECOND ELSEIF
and so on. I'm...
I've seen a few comments here that mention that modern regular expressions go beyond what can be represented in a regular language. How is this so? What features of modern regular expressions are not regular? Examples would be helpful.
...
I am using Text::CSV to parse a csv file. Not all lines can be parsed, because of some bad characters.
The Text::CSV documentation says:
Allowable characters within a CSV field include 0x09 (tab) and the inclusive range of 0x20 (space) through 0x7E (tilde).
How can I filter out as easy as possible any not-allowed characters?
...
Hello.
I need to validate a email address the best way, and I need to include some danish characters:
Æ Ø Å
æ ø å
My current regex is:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
How to incorporate the extra letters, and is there any optimizing that can be done to ensure the best handling of the e-mail address?
...
Hi,
did anybody know a good regex tester for javascript (i think there are differents between php regex and javascript? right?)
Thanks in advance!
Peter
...
Hi all:
What's the intent of () inside the regex? Thanks.
pattern.replace(/\{(\d+)\}/g,
function(pattern, index) {
return args[index].toString();
});
PS: args is something like ["3", "dl1", "42"]
...
I am trying to add wild characters to my current alphanumeric only regular expression to make the password validation stronger. I am not trying to require the user to enter wild characters, just allowing them to enter wild characters.
'/^[a-z0-9]{8,16}$/i'
I am also using cakephp and doing the validation in the model if that helps, bu...
irb(main):051:0> "ts_id < what".gsub(/(=|<|>)\s?(\w+|\?)/,"#{$1} ?")
=> "ts_id > ?"
irb(main):052:0> "ts_id < what".gsub(/(=|<|>)\s?(\w+|\?)/,"#{$1} ?")
=> "ts_id < ?"
Can anyone enlighten me?
...
my regular expression is currently:
includes.push\("([^\"\"]*\.js)"\)
but it matches all of the following lines
/*includes.push("javascriptfile.js")*/
/*
includes.push("javascriptfile.js")
*/
includes.push("javascriptfile.js");
includes.push("javascriptfile.js")
And I don't want it to match the lines within comments.
Any regex exp...
Hi
I'm having a problem finding out how to replace the last ', ' in a string with ' and ':
Having this string:
test1, test2, test3
and I want to end out with:
test1, test2 and test3
I'm trying something like this:
var dialog = 'test1, test2, test3';
dialog = dialog.replace(new RegExp(', /g').lastIndex, ' and ');
but it's not w...
I am trying to remove the webpage part of the URL
For example,
www.example.com/home/index.html
to
www.example.com/home
any help appreciated.
Thanks
...
Ok so I managed to solve a problem at work with regex, but the solution is a bit of a monster.
The string to be validated must be:
zero or more: A-Z a-z 0-9, spaces, or these symbols: . - = + ' , : ( ) /
But, the first and/or last characters must not be a forward slash /
This was my solution (used preg_match php function):
"/^[a-z\...
I'm creating a program where I need to search an FTP server and download all files which match a given regex. How do I do this? I can connect to the FTP server, but how do I scan all files in the given path for files matching the regex?
I also need to do the same for HTTP servers which I think will be fundamentally more difficult, but I...
string.replace(/([\t])/g,"\\$1")
is working fine where
string.replace(/([\n])/g,"\\$1")
is not working!!!
any idea please???
N.B. string.replace(/\n/g,"\\n") is also working fine
...
$ cat names
projectname_flag_jantemp
projectname_flag_febtemp
projectname_flag_marchtemp
projectname_flag_mondaytemp
$
Perl code:
my $infile = "names";
open my $fpi, '<', $infile or die "$!";
while (<$fpi>) {
my $temp = # what should come here? #
func($temp);
}
I want temp to have
jan
feb
march
monday
respectively.
The p...