regex

How to upload Only Excel file using RegularExpressionValidator?

i need to control Only ExcelFile uploading with RegularExpressionValidator How can i do that? i need to write a regex pattern in ValidationExpression... <h3>FileUpload Test</h3> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click" runat="ser...

PHP reqular expression: extracting title of img tag

I'm trying to learn reg exp, i want to get title of <img only from the text the text is differ and basically look like this <a href="http://abcde.com" target="_blank"><img src="http://abcde.com/img/aa.jpg" title="img title" id="img id" class="img class" /> any guidance and advise are appreciated.. ...

django url regex

Hello, I want my urls.py to capture a long url setting as such: /get/<lowercase_string>/<integer>/<date>/<date>/ For instance: www.mysite.com/get/ams/221/12-23-2010/01-10-2011/, as you may see date is in month/day/year format. As my regex knowledge is near to nothing, I will be grateful for you guidance. I will be capturing <lowercas...

RegEx - Java Split Command Parsing Csv File

I have a CSV in this below format 11000,Christopher,Nolan,MR.,Inception,25993,France,"Lefoullon,Paris",920,Director,*461-7755,33-461-7755,12175,"O'Horner, James",12300,"Glebova, Nathalie",,[email protected],Capital,NEW http://stackoverflow.com/questions/2241758/regarding-java-split-command-parsing-csv-file In this link @Mar...

regular expression anchor tag

hi to all i am using php and i am having problem to parse the href from anchor tag with text. example: anchor tag having test http://www.test.com like this <a href="http://www.test.com" title="test">http://www.test.com&lt;/a&gt; i want to match all text in anchor tag thanks in advance. ...

regex to check the string contains only letter and numbers but not only numbers

hi, I need a help with regex which checks the string contains only letter and numbers but not only numbers Valid * letters * 1wret * 0123chars * chars0123 * cha2rs Invalid * 1324 * xcvxxc%$# * xcv123xxc%$# * _012chars * _test ...

regex taken from jQuery.validate email method doesn't work with my php script

Hi I have a form with jQuery.validate. It checks if typed email is correct using it's own method. What i would like to achieve is to use the regex from it with my server-side php input validation. The regex i'm talking about: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.( [a-z]|\d|[!#\$%&'...

Why are most string manipulations in Java based on regexp?

In Java there are a bunch of methods that all have to do with manipulating Strings. The simplest example is the String.split("something") method. Now the actual definition of many of those methods is that they all take a regular expression as their input parameter(s). Which makes then all very powerful building blocks. Now there are tw...

How to remove numbers from a string with RegEx

I have a string like this: " 23 PM" I would like to remove 23 so I'm left with PM or (with space truncated) just PM. Any suggestions? Needs to be in PHP ...

Regex PHP remove certain keyword

Hi, After viewing some answers on stackoverflow, preg_match_all('/<img[^>]+>/i',$html, $result); $img = array(); foreach( $result[0] as $img_tag) { preg_match_all('/(title)=("[^"]*")/i',$img_tag, $img[$img_tag]); } //print_r($img); foreach ($img as $imgg) echo $imgg[2][0]; The above code finds img title, but however it return a...

preg_match to .NET equivalent

I have the following code in PHP: if (preg_match('@^[a-z0-9/._-]+$@i', $script) && !preg_match('@([.][.])|([.]/)|(//)@', $script)) I'm making the assumption that the predicate for the if statement returns true for the string js/core.js. How would I translate this to C#? The dumb translation is as follows: if(Regex.IsMatch(...

subsitute word from regex to another word

Hello again, I have the following code with me, it produce the img title of specified text, let say the title = waterfallfountainpicture20x20, how do i replace the word fountain with lagoon so it would become waterfalllagoonpicture20x20? preg_match_all('/<img[^>]+>/i',$html, $result); $img = array(); foreach( $result[0] as $img_tag) { ...

Regular expression: find range except for one letter or a range

Hello, How can I use the negation within square brackets as an exception, to find e. g. everything between a-z except for the the range from m-o? [a-z^m-o]? Thanks in advance! By the way: it's not for the sake of this example that I ask, but to be able to exclude ranges within ranges, or even single letters within ranges. I am pretty ...

Regular Expression For Quoted String

If I have the following data: "test1"."test2" AND "test1"."test2" What regex can I use to match "test1"."test2"? I tried the following but it did not work. \b"test1"."test2"(\s+|$) In the given example I'd like to match "test1"."test2", and, "test1"."test2" ...

Question about a weird Java regex behavior

I'm working on a regex that could match the leading digits and . in a String. But it seems just not working correctly. The regex I'm using is "^[\\.\\d]+" Below is my code: public void testMiscellaneous() throws Exception { System.out.println("~~~~~~~~~~~~~~~~~~~testMiscellaneous~~~~~~~~~~~~~~~~~~~~"); String s1 = ".123 *[DP...

Java RegEx replaceAll throws ArrayIndexOutOfBoundsException

I am trying in Java to surround a word in HTML with some markup. This code throws a ArrayIndexOutOfBoundsException when the replaceAll is called. Pattern pattern = Pattern.compile(wordToHighlight + "\\w{0,5}"); String replacement = "<span class='highlight'>$1</span>"; Matcher matcher = pattern.matcher(html); if (matcher != null) if...

Using preg_replace without destroying id information

I'm trying to hack about some sidebar code in a Wordpress template I'm developing. Basically I've captured what I need in an output buffer and I'm running regex over it to replace bits with the code I need. Problem is my regex knowledge is just a bit short on what I need to achieve. The problem I'm having is as such: $output = preg_rep...

Fast Text Preprocessing

In my project I work with text in general. I found that preprocessing can be very slow. So I would like to ask you if you know how to optimize my code. The flow is like this: get HTML page -> (To plain text -> stemming -> remove stop words) -> further text processing In brackets there are preprocessing steps. The application runs in ab...

Match parts of any date anywhere in a string using regex

This has probably been answered dozens of times, couldn't find the answer though... Anyway, working in a Smalltalk environment I have a string composed of three parts like this: "ttm 4/6/97 00:08". The string is very variable, meaning some part may be missing (so it would be a string composed of less then three parts like "ttm 4/6/97") ...

getting rid of the ending of the url

I am using php and i want the part of the url without the /floor-plans/dsafasd so i want something/whatever instead of something/whatever/floor-plans/dsafasd ...