Folks does anyone knows of a PHP function to remove unmatched HTML tags from a string. for example<div> This is a string <b> with an unmatched bold tag </div>. If there isnt one then help me buld one, maybe I can have a function that counts the number of opening tags and matching closing tags. If they are not even then remove the first o...
Is there any way to have this:
[one[two]][three]
And extract this with a regex?
Array (
[0] => one[two]
[1] => two
[2] => three
...
Hello, in writing a scripting engine, I have functions like (psuedo-code)
function is_whitespace?(char c){
return c==' ' || c=='\t' || c=='\r' || c=='\n';
}
Well, my question is which is faster in most langugaes? That or using regex like
function is_whitespace?(char c){
return regex_match('\s',c);
}
The chief languages I'm conc...
I have a function with a python doctest that fails because one of the test input strings has a backslash that's treated like an escape character even though I've encoded the string as a raw string.
My doctest looks like this:
>>> infile = [ "Todo: fix me", "/** todo: fix", "* me", "*/", r"""//\todo stuff to fix""", "TODO f...
I want to capture everything up to (not including) a # sign in a string. The # character may or may not be present (if it's not present, the whole string should be captured).
What would the RegEx and C# code for this by? I've tried: ([^#]+)(?:#) but it doesn't seem to work.
...
I'm currently trying to parse a document into tokens with the help of regex.
Currently I'm trying to match the keywords in the document. For example I have the following document:
Func test()
Return blablaFuncblabla
EndFunc
The keywords that needs to be matched is Func, Return and EndFunc.
I've comed up with the following regex: (...
Regex that somewhat validates if a value has one of the following characteristics:
123-29-123-123.subdomain.zomg.com:8085
123.12.34.56:420
Unfortunately, I'm terrible at Regex, C#, google searches, and the differences between proper nouns and regular ones.
It can be a lose approximation, in fact I would go with anything that has a : ...
I have a text source with nulls in it and I need to pull them out along with my regex pattern. Can regex even match a null character?
I only realized I had them when my pattern refused to match and when I pasted it into Notepad++ it showed all the null characters.
...
I'm using the following regex to validate password complexity:
/^.*(?=.{6,12})(?=.*[0-9]{2})(?=.*[A-Z]{2})(?=.*[a-z]{2}).*$/
In a nutshell: 2 lowercase, 2 uppercase, 2 numbers, min length is 6 and max length is 12.
It works perfectly, except for the maximum length, when I'm using a minimum length as well.
For example:
/^.*(?=.{6,})...
Hello,
Suppose I have a path in a string called '/home/user/directory/HelloWorld.txt'. I would like to remove the HelloWorld.txt, and end up with '/home/user/directory'. What regex would I need.
...
Hello guys,
I've searched but was unable to find an existing regex function. Has anybody done this before?
I wish to add a port number, or remove a potantially existing one from a url in php. To use in some functions which translate a given url to the secure one, unsecure one, etc.
Now I need a second SSL secured site on the server so...
How do I remove duplicate characters and keep the unique one only.
For example, my input is:
EFUAHUU
UUUEUUUUH
UJUJHHACDEFUCU
Expected output is:
EFUAH
UEH
UJHACDEF
I came across perl -pe's/$1//g while/(.).*\/' which is wonderful but it is removing even the single occurrence of the character in output.
...
Hello all,
I have a WordPress blog with numerous URL's I wish to replace from this:
http://www.oldwebsite.co.il/name/*.asp
To this:
http://www.newwebsite.com/?p=*
For example, from this:
http://oldwebsite.co.il/name/65971.asp
To this:
http://www.newwebsite.com/?p=65971
I believe the following plugin:
http://urba...
I am looking for a Regex that allows me to validate json.
I am very new to Regex's and i know enough that parsing with Regex is bad but can it be used to validate?
...
I am trying to perform some composition-based filtering on a large collection of strings (protein sequences).
I wrote a group of three subroutines in order to take care of it, but I'm running into trouble in two ways - one minor, one major. The minor trouble is that when I use List::MoreUtils 'pairwise' I get warnings about using $a and...
I'm trying to limit what our users will be able to type in inputs, using javascript/jquery.
Problem is, I have to limit this to Uppercase chars only, and numbers.
Here's what I coded previously :
$(input).keypress(function(e){
if ($(input).attr("class")=="populationReference"){
var ValidPat...
I need to get all characters between '(' and ')' chars.
var str = "dfgdgdfg (aaa.bbb) sfd (c) fdsdfg ( ,ddd (eee) )";
In this example, I need to get 3 strings:
(aaa.bbb)
(c)
( ,ddd (eee) )
What pattern I have to write? Please, help.
...
I have an html document with multiple commented-out PHP arrays, e.g.:
<!-- Array
(
[key] => 0
)
-->
Using PHP, I need to somehow parse the HTML for only these comments (there are other comments that will need to be ignored) and extract the contents. I've been trying to use preg_match_all but my regex skills aren't up to much. Could an...
Hi, i am seriously struggling to get my head around regex.
I have a sring with "iPhone: 52.973053,-0.021447"
i want to extract the two numbers after the colon into two seperate strings so delimited by the comma.
Can anyone help me? Cheers
...
Hi
I have to retrieve several div section (of specific class name "row ") with it's content, and additionally find all anchor tags (link urls) (with class "underline red bold").
Shortly speaing : get section of:
<div class = "row ">
... (divs, tags ...)
<a class="underline red bold" href="/searchClickThru?pid=prod56534895&q=&r...