I want my regex to catch:
monday mon thursday thu ...
So it's possible to write something like this:
(?P<day>monday|mon|thursday|thu ...
But I guess that there should be a more elegant solution.
hi all,
i'm having the following string
<img alt="over 40 world famous brandedWATCHES BRANDs to choose from
" src="http://www.fastblings.com/images/logo.jpg"></strong></a><br>
i want to define a regex pattern like <img alt="(.+?)" src="http://(.+?).(jpg|gif)">
but as u can see the target strings has a linebreak in the alt attribute - so how can i incorporate this? the rule should be like "anything in the alt-attribute including linebreaks"
thx
I want regular expression that checks
that the string doesnt start with an
empty space.
Some what like this i want to do :
Is the below ValidationExpression right for it :
string ValidationExpression = @"/^[^ ]/";
if (!String.IsNullOrEmpty(GroupName) && !Regex.IsMatch(GroupName, ValidationExpression))
{
}
I am trying to write a regular expression for somethin like
s1 = I am at Boston at Dowtown
s2 = I am at Miami
I am interested in the words after at eg: Boston, Downtown, Miami
I have not been successful in creating a regex for that. Somethin like
> .*? (at \w+)+.*
gives just Boston in s1 (Downtown is missed). it just matches the first "at" Any suggestions
I have a program that does string manipulation on very large strings (around 100K). The first step in my program is to cleanup the input string so that it only contains certain characters. Here is my method for this cleanup:
public static String analyzeString (String input) {
String output = null;
output = input.replaceAll("[-+.^:,]","");
output = output.replaceAll("(\\r|\\n)", "");
output = output.toUpperCase();
output = output.replaceAll("[^XYZ]", "");
return output;
}
When i print my 'input' string of length 97498, it prints successfully. My output string after cleanup is of length 94788. I can print the size using output.length() but when I try to print this in Eclipse, output is empty and i can see in eclipse output console header. Since this is not my final program, so I ignored this and proceeded to next method that does pattern matching on this 'cleaned-up' string. Here is code for pattern matching:
public static List<Integer> getIntervals(String input, String regex) {
List<Integer> output = new ArrayList<Integer> ();
// Do pattern matching
Pattern p1 = Pattern.compile(regex);
Matcher m1 = p1.matcher(input);
// If match found
while (m1.find()) {
output.add(m1.start());
output.add(m1.end());
}
return output;
}
Based on this program, i identify the start and end intervals of my pattern match as 12351 and 87314. I tried to print this match as output.substring(12351, 87314) and only get blank output. Numerous hit and trial runs resulted in the conclusion that biggest substring that i can print is of length 4679. If i try 4680, i again get blank input. My confusion is that if i was able to print original string (97498) length, why i couldnt print the cleaned-up string (length 94788) or the substring (length 4679). Is it due to regular expression implementation which may be causing some memory issues and my system is not able to handle that? I have 4GB installed memory.
What is the best way to validate a crontab entry with PHP? Should I be using a regex, or an external library? I've got a PHP script that adds/removes entries from a crontab file, but want to have some way to verify that the time interval portion is in a valid format.
I have a form with a textarea in it. I log the results to a text file on the server, but I would like to strip out any line breaks a user would put in the textarea, as well as any commas that would interfere with importing the comma-delimited log text file into Excel or something for later use.
I think this has to do with regex, but I'm no expert and could use some help. Or maybe there is an easy PHP function that will do it?
What would the regex expression that would go into preg_split function to validate date in the format of
7-Mar-10 or how can I validate a date of format 7-Mar-10 in PHP
Thanks.
Hi.
Tumblr and other blogging websites allows people to post embeded codes of videos from youtube and all video networks.
but how they filter only the flash object code and remove any other html or scripts? and even they have an automated code that informes you this is not a valid video code.
Is this done using REGEX expressions? And Is there a PHP class to do that?
Thanks
Hi,
I've got this regex (I'm not good at it) /http://www.youtube.com/watch?v=[a-zA-Z0-9_]/i it has to match any youtube watch url (because youtube always redirects to that domain)... It should match http://www.youtube.com/watch?v=iMXCqgWjpL8 but it doesn't.
Can someone help me?
Regard,
dodo
Hi
with linux bash shell , how can i use regex to get a certain string of a file
by example:
for filename *.tgz
do
"get the certain string of filename (in my case, get 2010.04.12 of file 2010.01.12myfile.tgz)"
done
or should I turn to perl
Merci
frank
I have the following regex expression which is to extract the source of any img tag in HTML.
/(<img).*(src\s*=\s*"([a-zA-Z0-9\.;:\/\?&=\-_|\r|\n]{1,})")/isxmU
However, it doesn't appear to be matching the following:
<IMG SRC='http://www.mysite.com/pix/lens/mtf/CAEF8512L.gif'>
How can I build it to match this as well?
I have a string like so:
option_alpha="value" option_beta="some other value" option_gamma="X" ...etc.
I'm using this to parse them into name & value pairs:
preg_match_all("/([a-z0-9_]+)\s*=\s*[\"\'](.+?)[\"\']/is", $var_string, $matches)
Which works fine, unless it encounters an empty attribute value:
option_alpha="value" option_beta="" option_gamma="X"
What have I done wrong in my regex?
Hello, please, does any of you knows and can share an easy/clean way to find a substring within a string, but ignoring some specified characters to find it.
I think an example would explain things better:
string: "Hello, -this- is a string"
substring to find: "Hello this"
chars to ignore: "," and "-"
found the substring, result: "Hello, -this"
Using Regex it's not a requirement for me, just added the tag because it feels related.
Hi Guys,
I have a bit of php code like this:
$test = "<!--my comment goes here--> Hello World";
Now i want to strip the whole html comment from the string, i know i need to use preg_replace, but now sure on the regex to go in there.
Can anybody help?
Thanks
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://anything.abc.tld/xyz is not acceptable.
I have a variable $link_item, it's used with echo and gives the strings like
<span class="name">Google</span>http://google.com
How to remove "<span class="name">Google</span>" from string?
It should give just "http://google.com".
Heard it can be done with regex(), please help.
I know that the following regex will match "red", "green", or "blue".
red|green|blue
Is there a straightforward way of making it match everything except several specified strings?
Trying to use regex refind tag to find the content within the brackets in this example using coldfusion
joe smith <[email protected]>
The resulting text should be
[email protected]
Not having any luck. Any suggestions?
Regex is absolutely my weak point and this one has me completely stumped. I am building a fairly basic search functionality and I need to be able to alter my user input based on the following pattern:
Subject:
%22first set%22 %22second set%22-drupal -wordpress
Desired output:
+"first set" +"second set" -drupal -wordpress
I wish I could be more help as I normally like to at least post the solution I have so far, but on this one I'm at a loss.
Any help is appreciated. Thank you.
My string contain a lot of HTML entities, like this
"Hello <everybody> there"
And I want to split it by HTML entities into this :
Hello
everybody
there
Can anybody suggest me a way to do this please? May be using Regex?
Alright so I want to grab the information on a website thats between
[usernames] and [/usernames]
I know how to get the string but how would I use regex to only have the information in the middle.
Remember I am going to be having more then one thing on the page.
I am using python and would like a simple api or regex to check for a domain name's validity. By validity I am the syntactical validity and not whether the domain name actually exists on the Internet or not.
Hi to all,
if I have a string like 'foo(bar)', with the following code i can almost parse it the way i want:
$results = array();
preg_match( "/\w*(?=(\(.*\))?)/", 'foo(bar)', &$results );
print_r($results);
/*
Array
(
[0] => foo
[1] => (bar)
)
*/
How can I modify the regex to have bar instead of (bar)? Thanks