I have a regular expression in PHP that looks for the date in the format of YYYY-MM-DD
What I have is: [\d]{4}-[\d]{2}-[\d]{2}
I'm using preg_match to test the date, the problem is that 2009-11-10 works, but 2009-11-1033434 works as well. It's been awhile since I've done regex, how do I ensure that it stops at the correct spot? I've ...
Not sure what this is called, but is there a way I can pull data from a file, echo it, but ignore data within a certain set of characters?
<?php
echo file_get_contents('test.txt');
?>
Would it be possible to ignore the data in between the asterisks, and the asterisks themselves when I echo out the final function?
...
Here is the pattern that I want to match:
<div class="class">
<a href="http://www.example.com/something"> I want to be able to capture this text</a>
<span class="ptBrand">
This is what I am doing:
$pattern='{<div class="productTitle">[\n]<((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)>([...
I want to check posted content against a pattern. I am having trouble setting up this preg_match (or array?). The pattern being...
TEXTHERE:TEXTHERE
TEST:TEST
FILE:FILE
AND
TEXTHERE:TEXTHERE TEST:TEST FILE:FILE
I want to check for either pattern, the one with the whitespace and the one with the line break. If the posted content is...
I am trying to find a php preg_match that can match
test1 test2[...] but not test1 test2 [...]
and return test2(...) as the output as $match.
I tried
preg_match('/^[a-zA-Z0-9][\[](.*)[\]]$/i',"test1 test2[...]", $matches);
But it matches both cases and return the full sentence.
Any help appreciated.
...
There are no multibyte 'preg' functions available in PHP, so does that mean the default preg_functions are all mb safe? Couldn't find any mention in the php documentation.
...
I need to extract the digits from the following string using regular expression:
pc 32444 xbox 43567
so my array will be
array ([0] => 32444 [1] => 43567)
Can someone help construct a preg_match for me?
Thanks!
...
I am searching a string for urls...and my preg_match is giving me an incorrect amount of matches for my demo string.
String:
Hey there, come check out my site at www.example.com
Function:
preg_match("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", $string, $links);
echo count($links);
The result comes out as 3.
Can anybody help...
I want to accept a list of character as input from the user and reject the rest. I can accept a formatted string or find if a character/string is missing.
But how I can accept only a set of character while reject all other characters. I would like to use preg_match to do this.
e.g. Allowable characters are: a..z, A..Z, -, ’ ‘
User must ...
My string of text looks like this
[email protected] (John Doe)
I need to get just the part before the @ and nothing else. The text is coming from a simple xml object if that matters any.
The code i ahve looks like this
$authorpre = $key->{"author"};
$re1='((?:[a-z][a-z]+))';
if ($c=preg_match_all ("/".$re1."/is", $authorpre, $matc...
I've been using "/x{201C}/u" and "/x{201D}/u" to match them, but there's no result.
Am I doing something wrong??
...
Hi,
I am trying to get the search keyword from a referrer url. Currently, I am using the following code for Google urls. But sometimes it is not working...
$query_get = "(q|p)";
$referrer = "http://www.google.com/search?hl=en&q=learn+php+2&client=firefox";
preg_match('/[?&]'.$query_get.'=(.*?)[&]/',$referrer,$search_keyword);
...
How to preg_match for an null (empty) string??
I need something like:
/([0-9]|[NULL STRING])/
...
I am trying to create a script that will only execute its actions if the email address the user enters is from a specific domain. I created a regex that seems to work when testing it via regex utility, but when its used in my PHP script, it tells me that valid emails are invalid. In this case, I want any email that is from @secondgear...
I already have a function that counts the number of items in a string ($paragraph) and tells me how many characters the result is, ie tsp and tbsp present is 7, I can use this to work out the percentage of that string is.
I need to reinforce this with preg_match because 10tsp should count as 5.
$characters = strlen($paragraph);
$items ...
I have this text file:
Dec 04 20:15 Naruto 123
Dec 04 17:42 Naruto 98
Dec 04 16:19 D Gray Man 001
Dec 04 16:05 Bleach 128
Dec 04 12:13 50 x 50 44
I need to output the contents into a table with the Date and Time in its own column and the Tile and Chapter in another.
Also.. I need to replace the Title and Chapter with a link that must...
Just need to see if a paragraph contains a "stop word", the stop words are in an array below.
I had the formula as:
$pattern_array = array("preheat", "minutes", "stir", "heat", "put", "beat", "bowl", "pan");
foreach ($pattern_array as $pattern) {
if (preg_match('/'.$pattern.')/i', $paragraph)) {
$stopwords = 1;
...
I have a text file that reads:
9123 Bellvue Court
5931 Walnut Creek rd.
Andrew
Bailey
Chris
Drew
Earl
Fred
Gerald
Henry
Ida
Jake
Koman
Larry
Manny
Nomar
Omar
Perry
Quest
Raphael
State
Telleman
Uruvian
Vixan
Whales
Xavier
Yellow
Zebra
What I need to do is I need to create a A-Z listing... so:
# A B C D E F G H I J K L M N O P Q R S T ...
text text text
text text text
{test}
content
content
content
{/test}
text text text
text text text
i need to get two separate results from the above string:
1.
{test}
content
content
content
{/test}
2.
content
content
content
so, what should be the two separate regular expression patterns for...
Hey,
I need a function that matches full words in hebrew in php.
Please help.
...