Perl has been one of my go-to programming language tools for years and years. Perl 6 grammars looks like a great language feature. I'd like to know if someone has started something like this for Ruby.
...
I'm writing a .NET 3.5 app and using URI.IsWellFormedUriString(string uriString, UriKind uriKind) to verify user-inputted URIs; using UriKind.Absolute. I was just playing with the application and I'm a bit worried and confused as to why something like:
http://ddd
is a valid URI? What gives? I know it's because it's part of the RFC, b...
Are there any regex experts who can help me clean up the following source code? I'm going through some existing code and I see several instances similar to the following:
public enum Numbers
{
/// <summary>
/// One = 1,
/// </summary>
One = 1,
/// <summary>
/// Two = 2,
/// </summary>
Two = 2,
//...
I have fooled around with regex but can't seem to get it to work. I have a file called includes/header.php I am converting the file into one big string so that I can pull out a certain portion of the code to paste in the html of my document.
$str = file_get_contents('includes/header.php');
From here I am trying to get return only th...
first, this is using preg.
String I'm trying to match:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa b c d xp
My regex and their matches:
(\S*\s*){0,1}\S*p = "d xp"
(\S*\s*){0,2}\S*p = "c d xp"
(\S*\s*){0,3}\S*p = NO MATCH (expecting "b c d xp"
(\S*\s*){0,4}\S*p = entire string
(\S*\s*){0,5}\S*p = entire string
Oddly, if I remove a single ...
How can you match the following words by PHP, either by regex/globbing/...?
Examples
INNO, heppeh, isi, pekkep, dadad, mum
My attempt would be to make a regex which has 3 parts:
1st match match [a-zA-Z]*
[a-zA-Z]?
rotation of the 1st match // Problem here!
The part 3 is the problem, since I do not know...
If string "x" contains any letter or number, print that string.
How to do that using regular expressions?
Below is wrong?
if re.search('^[A-Z]?[a-z]?[0-9]?', i):
print i
...
I need an regular expression which matches the following:
'"test foo bar", "test"' => no match
'"test, foo bar", "test"' => "test, foo bar"
'"test, foo bar"' => "test, foo bar"
'"test foo bar"' => no match
'"test", "test, foo"' => "test, foo"
'"test", ","' => no match
'"test", 0, 0, "foo"' => no match
the regex should match any string...
Is it any faster to use
myString.replace(/foo/g,"bar")
rather than
myString.split("foo").join("bar")
for long strings in ActionScript 3? Or are they just two comparable methods of achieving the same result?
...
I have the following Regexp :
regexp=/(\w+) \s* : \s* (\w+) \s+ (.*) \s* ;?/ix
And I am trying to get the captures:
names, direction, type = iotext.match(regexp).captures
This works fine for a single "x : in integer;" ,
but how could I also get all the groups of other match data in my file :
"x : in integer;
y : in logic;
z : i...
I'm trying to use a Python regex to find a mathematical expression in a string. The problem is that the forward slash seems to do something unexpected. I'd have thought that [\w\d\s+-/*]* would work for finding math expressions, but it finds commas too for some reason. A bit of experimenting reveals that forward slashes are the culprit. ...
Hiho everyone! :)
I have an application, in which the user can insert a string into a textbox, which will be used for a String.Format output later. So the user's input must have a certain format:
I would like to replace exactly one placeholder, so the string should be of a form like this: "Text{0}Text". So it has to contain at least on...
I need to find the text 'ifeq ($(Param1)' using grep. I try to assign search result to make variable. The problem is that single quotes don't escape text in make so when I try:
GrepResult:= $(shell grep 'ifeq ($$(Param1)' TextFile)
I get:
Makefile:214: *** unterminated call to function `shell': missing `)'. Stop.
The $ can be esca...
The usual alpha symbol for regular expressions \w in the .NET Framework matches alphanumeric symbols, and thus is equivalent to [a-zA-Z0-9], right? There is any [a-zA-Z] equivalent in .NET?
...
$test = "!!! sdfsdf sd$$$fdf ___";
$test = str_replace(' ', '_', $test); // Turn all spaces into underscores.
echo $test."<br />"; // Output: !!!___sdfsdf___sd$$$fdf______
$test = preg_replace('/[^a-zA-Z0-9_-]/', '-', $test); // Replace anything that isn't alphanumeric, or _-, with a hyphen.
echo $test."<br />"; // Output: !!!___s...
The following lines of comma-separated values contains several consecutive empty fields:
$rawData =
"2008-02-06,8:00 AM,14.0,6.0,59,1027,-9999.0,West,6.9,-,N/A,,Clear\n
2008-02-06,9:00 AM,16,6,40,1028,12,WNW,10.4,,,,\n"
I want to replace these empty fields with 'N/A' values, which is why I decided to do it via a regex substitution.
...
Let's use this as sample data :
text=<<EOF
#if A==20
int b = 20;
#else
int c = 30;
#endif
And this code :
puts text.scan(/\#.*?\#/m)
Why is this only capturing this:
#if A==20
int b = 20;
#
I was expecting this to match as well:
#else
int c = 30;
#
What do I have to modify so that it captures that as well?...
Hello.
I have a string I need to parse. The problem is that some parts of the string is not always the same.
a3:S8:[gmpage]S17:Head GM
NecrocideS12:test [15158]
The first 18 chars are always the same, so those can i String.Substring() out with ease.
My problem is that the characters S12: not always is S12:, it could easily be S...
I need to remove the first three occurrences of space per line in a text file.
I have tried the following:
sed 's/ //3'
This only removes the third occurrence.
sed 's/ //3g'
This leaves the first three occurrences of space alone and removes all of the following, this is the exactly the opposite of what i want.
...
Hi folks,
I have the following javascript.
window.location.href = _searchUrl + query.replace(/\s+/g, '+')
.replace('/', '-')
.replace('\\','-')
this replaces all spaces with + and only the first \ and first / with a -.
i need to make it replace ALL \ a...