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.
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?
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?
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
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 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?
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.
In Java regular expression, it has "\B" as a non-word boundary.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
If I have a 'char', how can I check it is a non-word boundary?
Thank you.
I need a model for finding all of the regular expressions that would match a particular string. Basically, I need an algorithm for doing what I do to generate a regex search string from some pattern.
My purpose for this to create a list of potential regular expressions from a selection of text and order that list from least specific (i.e. string of characters with abitrary length) to most specific (i.e. the string itself) to be used in text editor.
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
i'm really not used to the split string method in c# and i was wondering how come there's no split by more than one char function?
and my attempt to try to split this string below using regex has just ended up in frustration.
anybody can help me?
basically i want to split the string below down to
aa**aa**bb**dd^__^a2a**a2a**b2b**dd^__^
into
aa**aa**bb**dd
a2a**a2a**b2b**dd
and then later into
aa
aa
bb
dd
a2a
a2a
b2b
dd
thanks!
Is there any difference in speed/memory usage for these two equivalent expressions:
Regex.IsMatch(Message, "1000")
Vs
Message.Contains("1000")
Any situations where one is better than other ?
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.
In C# what's the best way to remove blank lines i.e., lines that contain only whitespace from a string? I'm happy to use a Regex if that's the best solution.
I would like to extract some text between two points in a string, in Javascript
Say the string is
"start-extractThis-234"
The numbers at the end can be any number, but the hyphens are always present.
Ideally I think capturing between the two hypens should be ok.
I would like the result of the regex to be
extractThis
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
I want to extract email addresses from a large text file. what is the best way to do it?
My idea is to find '@' in the text and use Regex to find email address into substring at (for example) 256 chars before this position and length of 512.
I need a way to convert a number into formatted way by inserting comma at suitable places. Can it be done using regex?
Example:
12345 => 12,345
1234567 =>1,234,567
When validating an email address with the regex validation component, an additional RequiredFieldValidator must be added to ensure there is a value present.
I've mostly taken care of this with a CustomFieldValidator, and taking care of this with Javascript.
Is there a better way of doing this?
Hi,
Firstable i want to match if a string has the following format: $abc #xyz or $abc .xyz.
The abc and xyz mean only alphanumeric string.
If it's matched then i need to extract the first $abc and the last #xyz, all that using pure javascript and maybe regex.
The pattern is in the following order:
Dollar Sign
Unlimited alphanumeric string
space
a hash or point
Unlimited alphanumeric string
Thanks in advance for any help.
How can I use sed to replace this line
char * path_list_[1] = { "/some/random/path" };
with this line
char * path_list_[2] = { "lib/foo", "lib/bar" };
in a file named source.c
Notes:
* The path is really random.
* Your solution should only change this line in source.c
* I'm only interested in a sed oneliner.
You can use this Python regex as a starting point:
text = re.sub('static const char \* path_list_\[1\] = \{ "[^"]*" \};',
'static const char * path_list_[2] = { "lib/sun", "lib/matlab" };', text)
I've searched for this a bit but I must be using the wrong terms - does ruby have a way to grep for a string/regex and also return the surrounding 5 lines (above and below)? I know I could just call "grep -C 5 ..."or even write my own method, but it seems like something ruby would have and I'm just not using the right search terms.
My HTML looks like this:
<td class="main"><b>Product Weight (2.83 lbs in 1 container)</b></td>
I need to get the value 2.83 from the HTML.
Need help with the regex.
I have this:
Pattern p = Pattern.compile(
"<td\\sclass=\"main\"><b>Product\\sWeight\\s\\s((?:\\d+\\.)?\\d+ \\w{3})");
But doesn't seem to be working.
Am I missing an escape or something?
I imagine I should use Regex for that but I still scratch my head a lot about it (and the only similar question I found wasn't exactly my case) so I decided to ask for help. This is the input and expected output:
Input: "c-0.68219,-0.0478 -1.01455-0.0441 0.2321e-4,0.43212"
Output:"c -0.68219,-0.0478 -1.01455 -0.0441 0.2321e-4,0.43212"
Basically I need either commas or spaces as value separators, but I can't break the exponential index (e-4). Maybe do two successive replacements?
I'm having a string where i'm using some placeholders to replace it with some values based on an object.
It is like the following:
Hello User <#= UserName #>
I need to replace the <#= UserName # with a value.
How can this be done with a regex? Please help. I dont want a string replace solution. There are somany placeholders and hardcoding the <#= UserName # and replace with the value is pointless