How to group symbols for "not in range" expression in PHP?
<li class="first">list item 1</li>
<li class="second">list item 2</li>
<li class="third">list item 3</li>
<li class="fourth">list item 4</li>
...
I'd like to cath all li elements except one with class="second"
This does not work:
/(<li[^(class="second")]+</li>)/xsU
...
I've a generic DB query function that runs the following checks every time an SQL query is issued:
if (preg_match('~^(?:UPDATE|DELETE)~i', $query) === 1)
if (preg_match('~^(?:UPDATE|DELETE)~iS', $query) === 1)
if ((stripos($query, 'UPDATE') === 0) || (stripos($query, 'DELETE') === 0))
I know that a simple strpos() call is way faster ...
I am using regex in my PHP script to check a page for Rapidshare links, and load them into an array.
My code:
if(preg_match_all('/http:\/\/rapidshare\.com\/files\/.*?\/[^\s]+/', $links[0], $links))
{
print_r($links);
} else {
die('Cannot find post links :(');
}
It finds the links correctly, and puts them into an array:
Array...
I want a regular expression for a number which is a continuous string of digits with no spaces - Please help !
Thankyou
...
I'm not a RegEx expert so I'm using the following borrowed RegEx to validate email addresses:
^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$
A user has reported it's rejecting their email address of frank@brownlie.info. It's the "info" that's being rejected as "inf" works. So I did a bit of reading and learnt what the [\w]{2,3} syntax means and yes,...
Hi!
I have the following URL:
http://www.abebooks.com/servlet/BookDetailsPL?bi=1325819827&searchurl=an%3DLofting%252C%2BHugh.%26ds%3D30%26sortby%3D13%26tn%3DDOCTOR%2BDOLITTLE%2527S%2BGARDEN.
Where bi is a identifier for the specific book.
How can I extract the book id from the link?
Thanks!
...
string input = "aaaabbbccc12345677XXXXsfsfsrfsd";
MessageBox.Show(Regex.Match(input, "7(?<x1>.*)s").Groups["x1"].Value);
That Result
7XXXXsfsfsrf
OK
but i want XXXX Value Only HOW?
MessageBox.Show(Regex.Match(input, ".*7(?<x1>.*?)s").Groups["x1"].Value);
...
Hey, I am looking for a pattern that matches everything until the first occurrence of a specific character, say a ";" - a semicolon.
I wrote this:
/^(.*);/
But it actually matches everything (including the semicolon) until the last occurrence of the semicolon.
...
I have several sites listed in my htaccess file that I want banned but apparently, they are not being matched. I'm wondering if someone can tell me what I'm doing wrong. I have seen many tuts and all of them differ in one way or another so there is no way for me to know which way is the correct way.
This is the condition (one of them) i...
Hey,
I want to match a string to make sure it contains only letters.
I've got this and it works just fine:
var onlyLetters = /^[a-zA-Z]$/.test(myString);
BUT
Since I speak another language too, I need to allow all letters, not just A-Z. Also for eg
é ü ö ê å ø
does anyone know if there is a global 'alpha' term that includes all ...
Hi,
I have a regex that I am using to validate email addresses. I like this regex because it is fairly relax and has proven to work quite well.
Here is the regex:
(['\"]{1,}.+['\"]{1,}\s+)?<?[\w\.\-]+@[^\.][\w\.\-]+\.[A-Za-z]{2,}>?
Ok great, basically all reasonably valid email addresses that you can throw at it will validate. I kno...
In Oracle/PLSQL, the instr function returns the location of a substring in a string.
If the substring is not found, then instr will return 0.
I want to search multiple substrings in a string and return the first non-zero value. This can be acheived using regexp_instr, but I'd like a non-regexp_ solution.
Example:
regexp_instr('500 Or...
Hi,
I'm trying to write a regexp which will help to find non-translated texts in html code.
Translated texts means that they are going through special tag: or through construction: ${...}
Ex. non-translated:
<h1>Hello</h1>
Translated texts are:
<h1><fmt:message key="hello" /></h1>
<button>${expression}</button>
I've written th...
I know this is a simple thing. but i just cant make it work.
Req: A word which contain at least one number, alphabets (can be both cases) and at least one symbol (special character).
In c# (?=.[0-9])(?=.[a-zA-z])(?=.*[!@#$%_]) worked. But in javascript its not working.
Seems like it always look for number at the beginning since my con...
Hi,
I need help with writing regular expression for this pattern in PHP:
[[{"type":"media","view_mode":"small","fid":"1","attributes":{"width":0,"height":0,"src":"http://localhost/x.png"}}]]
This is part of the text and I am trying to replace this by something else.
Would like to use preg_replace_all() but can't figure out what wou...
Lets say we have some text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus cursus vestibulum quam, et tristique nisi tristique ac. Nam ac risus vehicula tortor facilisis tincidunt. Aliquam at nisi vel arcu aliquet dignissim nec et massa. Curabitur vel magna eros, accumsan rutrum augue. Lorem ipsum http://subdomain-1...
Have an envelope that I'm passing through a socket. Like
<task>
<doc>
This is the contents of a file
</doc>
</task>
Works great with text docs using a pattern like "<doc>(.*?)</doc>", Pattern.DOTALL
but put the contents of a word doc in there and can't get it out.
Any Ideas?
Jim
...
I'm working on a website where I have some text which I am using the RedCloth gem to markdown. basically I need to intercept some text before it gets to the gem, and parse the text with a colour code syntax gem. My regex is very poor (and I don't know if I can do this.) I need to select chucks of text and parse them before RedCloth gets ...
I need to find a regex that tests that an input string contains exactly 10 numeric characters, while still allowing other characters in the string.
I'll be stripping all of the non-numeric characters in post processing, but I need the regex for client-side validation.
For example, these should all match:
1234567890
12-456879x54
32122...
I'm trying to match everything, but everything between [ and ].
everything between [ and ] is
\[.+\]
everything, but everything between [ and ] is
[^(\[.+\])]+
The search text is
valid[REGEX_EMAIL|REGEX_PASSWORD|REGEX_TEST]
It matches "valid" and "REGEX_EMAIL|REGEX_PASSWORD|REGEX_TEST".
It is supposed to match "valid", but not...