I want to extract the base name from a image URL in Javascript. Would somebody care to give me a a hand on the Regex?
The rule would be:
return everything right of the last / left of the last .
www.domain.com/images/image.hires.jpg
if no . is found, return the full base name
www.domain.com/images/image_hi_res
I have a clumsy /\/[^...
Hi
I would like a regex that would make this:
VALUES('Hit 'n Run')
into
VALUES('Hit ''n Run')
Is this possible?
...
Hello
I'm trying to create a BBcode [code] tag for my rails forum, and I have a problem with the expression:
param_string.gsub!( /\[code\](.*?)\[\/code\]/im, '<pre>\1</pre>' )
How do I get what the regex match returns (the text inbetween the [code][/code] tags), and escape all the html and some other characters in it?
I've tried thi...
I figured out how to check an OR case, preg_match( "/(word1|word2|word3)/i", $string );. What I can't figure out is how to match an AND case. I want to check that the string contains ALL the terms (case-insensitive).
...
The regex foo/(\w*)/bar matches the string foo/123/bar.
This is probably something basic that I've missed about regexes, but often I only want to retrieve the substring between the slashes. Is there a simple .NET API I can use without having to access the groups collection? Or an alternative way of writing the regex?
Thanks!
...
Following on from a previous question in which I asked:
How can I use a regular expression to match text that is between two strings, where those two strings are themselves enclosed two other strings, with any amount of text between the inner and outer enclosing strings?
I got this answer:
/outer-start.*?inner-start(.*?)inner-end....
I am trying to use this block of code to replace ALL "123"'s in a long string with a different number.
var new_id = new Date().getTime();
$('#food').after(
"<div id='123' name='123'> etc etc".replace('123', new_id)
);
But it's only replacing the first 123 with the new_id. Is there a way to replace all of them?
...
Hello , I'm trying to build a short uri service with CI just so i can learn CI faster
anyway .. i got stuck at the routing
i hid the index.php then added the following route $route['([A-z0-9]{4})'] = "/forward/redirect/$1";
but it just shows my default controller
i also tried with htaccess
RewriteBase /
RewriteCond %{REQUEST_FILE...
This should be easy and this regex works fine to search for words beginning with specific characters, but I can't get it to match hashes and question marks.
This works and matches words beginning a:
r = re.compile(r"\b([a])(\w+)\b")
But these don't match:
Tried:
r = re.compile(r"\b([#?])(\w+)\b")
r = re.compile(r"\b([\#\?])(\w+...
I'd like to be able to, say, check the value of $1 inside the if block, to get the first backreference. However vimscript is not perl.
Is there some way to do this? I'm aware of the possibility of using \1, \2, etc., inside the regex, but I'd like to match and then use the values in subsequent statements, as is possible in perl, php, ...
Given the following django URL conf. entry:
url(r'^(?P<obj_ctype_name>\w+)/(?P<obj_id>\d+)/$',
views.obj_view,
name='obj_view')
How would I rewrite the parameter (?P<obj_ctype_name>\w+) to enforce that
it may only be one of "foo" "bar" or "baz" and still keep it as a named
parameter?
...
thought i would write some quick code to download the number of 'fans' a page had of fb, just b/c i thought would be interested to get a handle on the regex search in python.
for some reason despite a fair number of iterations i've tried, i cant get the following code to pick out the number of fans in the html - none of the other solut...
Hi everyone.
I am trying to create a regular expression that understands mathematical equations (>, <, =, <=, >=, !=). Which is something pretty simple. I have come up with:
/(.*)([!<>][=]|[<>=])(.*)/
But when I use this regex in PHP, with preg_match, if equation is XYZ!=ABC, it just matches with =. Shouldn't it match the first expr...
I'm working on a JMD (Java MarkDown) (a Java port of MarkDownSharp) but I'm having an issue with one regex in particular. For the file Markdown_Documentation_Syntax.text this regular expression dies:
private static final String BLOCK_TAGS_1 = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";...
Hello,
I am writing an iPhone app that has to pull raw HTML data off a website an grab the url of the links and the displayed text of a link.
For example in the like <a href="www.google.com">Click here to go to google</a>
It would pull grab
url = www.google.com
text = Click Here to go to google
I'm using the regexlite library but i...
I'm looking for a rather specific regex and I almost have it but not quite.
I want a regex that will require at least 5 charactors, where at least one of those characters is either a numeric value or a nonalphanumeric character.
This is what I have so far:
^(?=.*[\d]|[!@#$%\^*()_\-+=\[{\]};:|\./])(?=.*[a-z]).{5,20}$
So the problem i...
I would like to let my users use regular expressions for some features. I'm curious what the implications are of passing user input to re.compile(). I assume there is no way for a user to give me a string that could let them execute arbitrary code. The dangers I have thought of are:
The user could pass input that raises an exception...
In Python Regular Expressions,
re.compile("x"*50000)
gives me OverflowError: regular expression code size limit exceeded
but following one does not get any error, but it hits 100% CPU, and took 1 minute in my PC
>>> re.compile(".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?"*50000)
<_sre.SRE_Pattern object at 0x03FB0020>
Is that normal?
Should ...
i'm weak in regular expressions, i need to redirect any FileName.htm or FileName.html page request to ./#FileName, only if the request is incoming from an outside link. These files will all reside in the root directory.
this is what i have so far. it gives me errors : (
RewriteCond %{REQUEST_FILENAME} !index.html$|!index.htm$ [NC]
Rew...
Hello!
I have a string like "Welcome to McDonalds®: I'm loving it™"... I want to get rid of ":", "'", ® and ™ symbols, so I do the following:
$string = "Welcome to McDonalds®: I'm loving it™";
$string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string);
BUT on the output I receive:
"Welcome to McDonaldsreg Im loving ittrade"... so preg...