I think its simple but I am too dumb to write one. Can someone proovide me with a regular expression that checks a given string for atleast 1 letter and atleast 1 number.
Also please give some explanation.
...
simple one really, i've written a regular expression to find and replace tags with php constants from within a html snippet. my solution, which works, just doesn't feel right. how can this be improved?
preg_match_all('/\{CONSTANT_(.*)\}/', $final, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[1]); $i++) {
...
How would I use regex to parse the following:
<b>HelloWorld</b>
<p>This is a test</p>
<a href="myUrl">Google</a>
All html tags need to be removed and the urls extracted from hyperlink tags, and the result should be:
HelloWorld
This is a test
myUrl
...
I'm attempting to build a function that will return a regex that is dynamically created. The regex to create will be a range check between two numbers. So far I've got something similar to this (not finished as yet).
Is this approach valid, or is there an easier way that I'm overlooking?
Public Shared Function Range(ByVal Minimum As In...
My regex skill is... bad. I have this email body.
Hello World
[cid:[email protected]]
Hello World
[cid:[email protected]] [cid:[email protected]]
Hello World
And what I need is an array of the filenames.
preg_match_all("/\[cid:(.*)\@/", $string, $matches);
echo "<pre>";
print_r($matches...
I have a table with ~500k rows; varchar(255) UTF8 column filename contains a file name;
I'm trying to strip out various strange characters out of the filename - thought I'd use a character class: [^a-zA-Z0-9()_ .\-]
Now, is there a function in MySQL that lets you replace through a regular expression? I'm looking for a similar functiona...
I ran Perl::Critic on one of my scripts, and got this message:
Regular expression without "/x" flag at line 21, column 26. See page 236 of PBP.
I looked up the policy information here, and I understand that writing regular expressions in extended mode will help anyone who is looking at the code.
However, I am stuck as how to convert ...
I have been thinking about a regular expression that can transform a list like this:
1. 10.Things.I.Hate.About.You[1999]DvDrip[Eng]-Ray 699.68 MB
2. 100.Feet.2008.DvDRip-FxM 701.14 MB
3. 11 - 14 1 286.22 MB
4. 13_going_on_30(2004)[Brizzly] 700.23 MB
...
1 523. Waz 699.93 MB
1 524. We.Own.the.Night[2007]DvDrip[Eng]-Ray 700.87 MB
1 ...
I have this code, and I want to know, if I can replace only groups (not all pattern) in Java regex.
Code:
//...
Pattern p = Pattern.compile("(\\d).*(\\d)");
String input = "6 example input 4";
Matcher m = p.matcher(input);
if (m.find()) {
//Now I want replace group one ( (\\d) ) with number
//and group two...
Hi.
I wanted to ask why .NET regex doesn't treat \n as end of line character?
Sample code:
string[] words = new string[] { "ab1", "ab2\n", "ab3\n\n", "ab4\r", "ab5\r\n", "ab6\n\r" };
Regex regex = new Regex("^[a-z0-9]+$");
foreach (var word in words)
{
Console.WriteLine("{0} - {1}", word, regex.IsMatch(word));
}
And this is the r...
Hi,
I have a query that when I test it with "echo", works well:
$url = "http://search.twitter.com/search.json?q=&ands=&phrase=&ors=&nots=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
$contents = file_get_contents($url);
$...
Hi,
I am trying to get commented strings in my code using regular expression in php.
Let's say I have following string.
$string = "
///<summary>
///test
///</summary>
";
I use preg_match_all for regular expression function.
when I put $string to preg_match_all, it displays
Warning: preg_match() [function.preg-match]: Unkn...
I have a text file (basically an error log with date, timestamp and some data) in the following pattern:
mm/dd/yy 12:00:00:0001
This is line 1
This is line 2
mm/dd/yy 12:00:00:0004
This is line 3
This is line 4
This is line 5
mm/dd/yy 12:00:00:0004
This is line 6
This is line 7
I'm new at Perl and need to write a script that se...
I would like to use a regular expression to mask all but the first three alphanumeric characters of each word in a string using a mask character (such as "x"), so "1 Buckingham Palace Road, London" would become "1 Bucxxxxxxx Palxxx Roax, Lonxxx".
Keeping the first three characters is easily done using
s/\b(\w{0,3})(.*)\b/$1/g
but I c...
Hi,
I'm trying to create a regex to verify that a given string only has alpha characters a-z or A-Z. The string can be up to 25 letters long. (I'm not sure if regex can check length of strings)
Examples:
1. "abcdef" = true;
2. "a2bdef" = false;
3. "333" = false;
4. "j" = true;
5. "aaaaaaaaaaaaaaaaaaaaaaaaaa" = false; //26 letters
Here...
I've got an XML file which I read in as a mutable array (NSMutableArray).
It stores information like
( as given out by *NSLog(@"%@:%s GUI data: %@", [self class], cmd, guiData); )
{
Name = "PopUp1";
RegEx = "^(Person|Group|Other)\Z";
Description = "Please select from list...";
Title = "Type";
}
So now, how do I acces...
Hi,
I'm trying to learn myself some C++ from scratch at the moment.
I'm well-versed in python, perl, javascript but have only encountered C++ briefly, in a
classroom setting in the past. Please excuse the naivete of my question.
I would like to split a string using a regular expression but have not had much luck finding
a cle...
This question is similar to http://stackoverflow.com/questions/373156/what-is-the-safest-way-to-empty-a-directory-in-nix
I'm writing bash script which defines several path constants and will use them for file and directory manipulation (copying, renaming and deleting). Often it will be necessary to do something like:
rm -rf "/${PATH1}"...
I am creating very simple CMS for my organisation.
My strategy is to embed editable content between tags called < editable >. However to hide these from the browser I am commenting them out. So an example of an editable region will look like this.
<!-- <editable name="news_item> Today's news is ... </editable> -->
With the content "T...
I have been tasked to find Elvis (using eclipse search). Is there any regex that I can use to find him?
The "Elvis Operator" (?:) is a shortening of Java's ternary operator.
I have tried \?[\s\S]*[:] but it doesn't match multiline.
Is there such a refactoring where I could change Elvis into an if-else block?
...