regex

How to match the last url in a line containing multiple urls, using regular expressions?

I want to write a regex that matches a url that ends with ".mp4" given that there are multiple urls in a line. For example, for the following line: "http://www.link.org/1610.jpg","Debt","http://www.archive.org/610_.mp4","66196517" Using the following pattern matches from the first http until mp4. (http:\/\/[^"].*?\.mp4)[",].*? Ho...

How do I include a hyphen in a hyperlink Regex?

I am trying to find links in user entered text and convert them to link automatically. I am using current Regex as following, which good to find hyperlinks from text. Regex regexResolveUrl = new Regex("((http://|www\\.)([A-Z0-9.-:]{1,})\\.[0-9A-Z?;~&#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase); It is workin...

Using explicitly numbered repetition instead of question mark, star and plus

I've seen regex patterns that use explicitly numbered repetition instead of ?, * and +, i.e.: Explicit Shorthand (something){0,1} (something)? (something){1} (something) (something){0,} (something)* (something){1,} (something)+ The questions are: Are these two forms identical? What if you add possessive/re...

Regular Expression to extract HREFS

I'm looking for a regular expression that can extract the href from this: <a href="/tr/blog.php?post=3593&user=930"> There are hundreds of links on the page so I need to extract only those that contain /tr/blog.php So in the end I should be left with a list of links that start in /tr/blog Thanks for any help. It's really puzzling...

php preg_split w/regex

<?php $str = '17:30 Football 18:30 Meal 20:00 Quiet'; $chars = preg_split('/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); print_r ($chars); ?> returned: Array ( [0] => Array ( [0] => 17:30 Football 18:30 Meal 20:00 Quiet [1] => 0 ) ) while I was hoping for: Array ( [0] => Array ...

Java - Regular expression question

I am new to regular expressions. I want to use java's replaceAll() function to replace any CSS comments in a string. Basically I want to use regex to search for anything that is surrounded by "/*" and "*/" and replace it with "". ...

need to clean malformed tags using regular expression

Looking to find the appropriate regular expression for the following conditions: I need to clean certain tags within free flowing text. For example, within the text I have two important tags: <2004:04:12> and <name of person>. Unfortunately some of tags have missing "<" or ">" delimiter. For example, some are as follows: 1) <200...

Regex expression is too greedy

I'm writing a regular expression to match data from the IMDb soundtracks data file. My regexes are mostly working, although they are in places slurping too much text into my named groups. Take the following regex for example: "^ Performed by '?(?<performer>.*)('? \(qv\))?$" The performer group includes the string ' (qv) as well as ...

How do I specify a wildcard (for ANY character) in a c# regex statement?

Trying to use a wildcard in C# to grab information from a webpage source, but I cannot seem to figure out what to use as the wildcard character. Nothing I've tried works! The wildcard only needs to allow for numbers, but as the page is generated the same every time, I may as well allow for any characters. Regex statement in use: Regex...

String split array

Intention is to take a current line which contains commas, store trimmed values of all space and store the line into the array. Why does this not work? String[] currentLineArray = currentInputLine.replace("\\s", "").split(","); ...

Strange JavaScript Regular Expression Behavior

I'm getting different behavior from a regular expression in JavaScript depending on whether or not I declare it using literal syntax. Using a extremely simple test HTML file: <html> <head> <script type="text/javascript"> var s = '3'; var regex1 = /\d/; var regex2 = new RegExp('\d'); ...

Regular expression using + problem in js

I am using regular expression. In phone validation, i have to use the "+" sign in that. How to provide the + sign in regular expression. Because + sign indicates one or more of preceding character(s). Whether i will provide like this \+ ? ...

How to print string in this way

For every string, I need to print # each 6 characters. For example: example_string = "this is an example string. ok ????" myfunction(example_string) "this i#s an e#xample# strin#g. ok #????" What is the most efficient way to do that ? ...

php: regex remove bracket in string

hi, similiar like this example, http://stackoverflow.com/questions/1336672/php-remove-brackets-contents-from-a-string i have no idea to replace $str = '(ABC)some text' into $str = 'ABC'; currently use $str = preg_replace('/(.)/','',$str); but not works. how to fix this? ...

Split string by HTML entities?

My string contain a lot of HTML entities, like this &#x22;Hello&nbsp;&lt;everybody&gt;&nbsp;there&#x22; And I want to split it by HTML entities into this : Hello everybody there Can anybody suggest me a way to do this please? May be using Regex? ...

How to match Regex right to left in php

This my simple data : <table></table><table></table><table>aaa</table> how to replace <table></table><table></table>***<table>aaa</table>*** it should be return <table></table><table></table> ...

Regular expressions in a Python find-and-replace script? Update

I'm new to Python scripting, so please forgive me in advance if the answer to this question seems inherently obvious. I'm trying to put together a large-scale find-and-replace script using Python. I'm using code similar to the following: infile = sys.argv[1] charenc = sys.argv[2] outFile=infile+'.output' findreplace = [ ('term1', 'ter...

excluding a column in csv file with regex

Is there any way to exclude/delete/replace one field from a csv file with some regexp in notepad++? I have a csv file with some data like this: '1','data1','data2','data3','data4','data5','data6','data7','data8','data9', 'data10','data11','data12','data13','data14','data15','data16','data17','data18', 'data19','data20','data21','data22...

301 Redirects, and the correct regex to go with it

Hi Guys, I have several URLs that I want to redirect to the same place, however these are dynamic URLs. The structure is something like this: http://www.mysite.com/declaration/list?[query_string] What I think would be ideal for this situation is to use some regex in my .htaccess file to redirect all these links to the sites home p...

Automatically hyper-link URL's and Email's using C#, whilst leaving bespoke tags in place

I have a site that enables users to post messages to a forum. At present, if a user types a web address or email address and posts it, it's treated the same as any other piece of text. There are tools that enable the user to supply hyper-linked web and email addresses (via some bespoke tags/markup) - these are sometimes used, but not a...