I use this function to make URLs to clickable links but the problem is that when there is some Unicode character in the URL it becomes clickable links only before that character...
Function:
function clickable($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a class="und" href="\\1">\\1</a>', $text);
$t...
Hi
This reg exp search correctly checks to see if a string contains the text harry:
re.search(r'\bharry\b','[harry] blah',re.IGNORECASE)
However, I need to ensure that the string contains [harry]. I have tried escaping with various numbers of back-slashes:
re.search(r'\b\[harry\]\b','[harry] blah',re.IGNORECASE)
re.search(r'\b\\[h...
Hi
I have a method which parses a string in to a date, but i want to validate that i don't try to parse a non numeric string or a string which dosent represent a date or time format?
how can id o this?
at the moment i have:
if(string=~ /^\D*$/ )
{
return false
else
do something_else
}
this was fine for a non numeric string like "...
hi ,
how to identify odd 1's in a binary number my binary numbers is, i.e every odd bit is a 1 in binary number
1 1 0 0 1 0 0 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 1 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
11010101010101111110110
11101101010101100011011
11111100110101010111101
i want get output what bit ...
I'm using the following 2 methods to highlight the search keywords. It is working fine but fetching partial words also.
For Example:
Text: "This is .net Programming"
Search Key Word: "is"
It is highlighting partial word from th*is* and "is"
Please let me know the correct regular expression to highlight the correct match.
private s...
I have to validate username in my app so that it cannot contain two consecutive period symbols. I tried the following.
username.match(/(..)/)
but found out that this matches "a." and "a..". I expected to get nil as the output of the match operation for input "a.". Is my approach right ?
...
Hi,
Here's what I'd like to do with a regular expression: 2 steps:
(1) transform all variables in a selected area like this:
$Sejour_deb_mois
$Info_pays
to :
$SejourDebMois
$InfoPays
(2) transform all variables in a selected area like this:
$this->Sejour_deb_mois
$this->Info_pays
to :
$this->SejourDebMois
$this->InfoPays
An...
Given searchString = "23423asdfa-''"
This regular expression should evaluate to false but it does not! Any ideas?
Regex rgx = new Regex(@"[\w-]*");
rgx.IsMatch(searchString)
...
Hi,
I have been trying to shortern this route:
http://abc.localhost/user/view/index/id/1
to this:
http://abc.localhost/user/1
with the following portion of code in my bootstrap but I keep getting an error stating that the 'Reversed route is not specified', any ideas why?
$route = new Zend_Controller_Router_Route_Regex(
'user/(\d+...
I need a regular expression to parse words from a sentence or a paragraph. Some separaters that should be used are: spaces, and dots. So in:
My name is Bob.I'm 104 yrs old.
Bob and I'm are seperated even though there isn't any space between them, but a dot.
Any other regular seperaters of words should also be included.
...
I have some useful regexes in Perl. Is there a simple way to translate them to .NET's dialect of regex? If not, is there a concise reference of differences?
...
I'm building a custom page caching utility that uses a syntax like {Substitution:GetNonCachedData} to get data that's not supposed to be cached. The solution is very similar to the built-in <@ OutputCache %> stuff but not as flexible (I don't need it to be) and, most importantly, allows the session state to be available when retrieving n...
I'm trying to split the following text:
<word>test</word><word>test2</word>
etc via the following reg ex:
preg_split(":</?word>:is", $html);
I get the result: test and test2 as the result, but what I need is to retrain the <word> and </word> tags, so instead of just test and test2, i get another 4 elements with the matching tags in ...
$lineArray = preg_split('/\t\s*(?=([^"]*"[^"]*")*[^"]*$)/', $line);
Above code snippet it to split a tab delimited file where tabs are not inside double quotes. It works fine except the cases where there double tabs (missing fields). Basically PHP sees only one tab when there are two. Is there a tab-width option?
...
I have this
/([^\/\|\#\<\(\>\;\s][0-9]*[\s][KB]{2})
in order to be specific i had to use [KB]{2}
I get the value needed, but can I convert the final print to MB?
Exemple: match= 2000KB = 2MB?
Thanks
...
price:(?:(?:\d+)?(?:\.)?\d+|min)-?(?:(?:\d+)?(?:\.)?\d+|max)?
This Regex matches the following examples correctly.
price:1.00-342
price:.1-23
price:4
price:min-900.00
price:.10-.50
price:45-100
price:453.23-231231
price:min-max
Now I want to improve it to match these cases.
price:4.45-8.00;10.45-14.50
price:1.00-max;3-12;23.34-1...
I get the file size from the index of the page, it's 1024KB and I want it to print 1MB stead of 1024KB, what should I do? (completely noob here)
I got this:
if($row[2]==1) // Rapidshare Check
{
$index=getpage($row[1]);
if(strpos($index,"FILE DOWNLOAD")===false) //check if page contains the word file download if not = bad link
{...
Say $d is a directory path and I want to ensure that it starts and ends with exactly one slash (/). It may initially have zero, one or more leading and/or trailing slashes.
I tried:
preg_replace('%^/*|/*$', '/', $d);
which works for the leading slash but to my surprise yields two trailing slashes if $d has at least one trailing slash...
Hello I want to make something like a meta language which gets parsed and cached to be more performant. So I need to be able to parse the meta code into objects or arrays.
Startidentifier: {
Endidentifier: }
You can navigate through objects with a dot(.) but you can also do arithmetic/logic/relational operations.
Here is an example o...
Hello, how do I match this phone number in Javascript?
> str
"(555) 555-3300"
> str.match( '/\(555\) 555-3300/gi/' )
null
> str.match( '/(555) 555-3300/gi/' )
null
I bet someone can answer this in 2 seconds. Googling the problem didn't help me.
Update
Also tried without the quotes:
str.match(/\(555\) 555-3300/gi/)
SyntaxError: Unex...