regex

What is the regular expression for valdating a 'price' in a jtextfield

I want to validate a jtextfield as user inputs a price of some item. I have a perfectly working code which beeps and discard if user inputs some character that doesnt match the regular expression.(for regular expression "[0-9]+" it accepts any number of digits and beeps if a letter is given as input) But the problem is I want to valida...

.NET Regex pattern?

var flashvars = { "client.allow.cross.domain" : "0", "client.notify.cross.domain" : "1", }; For some strange reason does not want to be parsed with this code (in C#). private void parseVariables() { String page; Regex flashVars = new Regex("var flashvars = {(.*?)}", RegexOptions.Multiline | RegexOptions....

php regex unlimited pattern

I'm looking to extend the regex below so I can have unlimited number of braces. ((?:{[0-9]:[a-z]+})?) So my string can handle {1:foo}{2:bar}{3:more} Any ideas will be appreciate it! ...

How can I convert SQL comments with -- to # using Perl?

UPDATE: This is what works! fgrep -ircl --include=*.sql -- -- * I have various SQL files with '--' comments and we migrated to the latest version of MySQL and it hates these comments. I want to replace -- with #. I am looking for a recursive, inplace replace one-liner. This is what I have: perl -p -i -e 's/--/# /g'` ``fgrep -- -- ...

Forbidden Patterns Check-In Policy in TFS 2010

I've been trying to use the Forbidden Patterns part of the TFS 2010 Power Tools and I'm just not understanding something - I simply cannot get anything to change as I try to use this! I'm using the version that was released recently (I believe April 23, 2010), so it's not an old version. First off, yes, I know it's regex based, so let's...

Alter Regular Expression to Return 2 Values Instead of 3 from userAgent String

I've taken a regular expression from jQuery to detect if a browser's engine is WebKit and gets it's version number, it returns 3 values extracted from the userAgent string: webkit/….…, webkit and ….… [“….…” being the version number]. I would like the regular expression to return just 2 values: webkit and ….…. I'm rubbish at regular exp...

C# Regular Expression to find multiple sequences of punctuation characters

I'm trying to match punctuations using regular expressions. Do I have to specify every punctuation character I am searching for or is there is an escape sequence I can use? I'm sitting here smiling to myself that the answers I might get will just be "Yes" or "No", please elaborate.... (that sentence should match the regular expression ...

Python match and return string in between

I have stringA = "xxxxxxFoundAaaaaaaaaaaaaaaFoundBxxxxxxx" stringB = "FoundA" stringC = "FoundB" How do I do a regular expression in python in order to return aaaaaaaaaaaaaa? Please help. Thanks in advance. ...

Help for splitting a string in JavaScript

I'd asked a question about the splitting the a string like below: Input string: a=>aa| b=>b||b | c=>cc and the output: a=>aa b=>b||b c=>cc Kobi's answer was: var matches = "a=>aa|b=>b||b|c=>cc".match(/(?:[^|]|\|\|)+/g) His answer worked, but I need to use the .split() method and store the outputs in an array. So I can't use the ...

Regex Lookaheads

Need to capture content of root <pubDate> element, but in document it can be either within <item> element or within <channel> element. Also <item> is child of <channel> I'll bring example <channel> ... <pubDate>10/2/2010</pubDate> ... <item> ... <pubDate>13/2/2029</pubDate> ... </item> ... </channel> need to ca...

What is the equivalent of REGEXP_SUBSTR in mysql?

I want to extract a word from a string column of a table. description =========================== abc order_id: 2 xxxx yyy aa mmm order_id: 3 nn kk yw Expected result set order_id =========================== 2 3 Table will at most have 100 rows, text length is ~256 char and column always has one order_id present. So performance is ...

removing non ascii characters from a string using python / django

I have a string of HTML stored in a database. Unfortunately it contains characters such as ® I want to replace these characters by their HTML equivalent, either in the DB itself or using a Find Replace in my Python / Django code. Any suggestions on how I can do this? ...

PHP Regex: How to match anything except a pattern between two tags

Hello, I am attempting to match a string which is composed of HTML. Basically it is an image gallery so there is a lot of similarity in the string. There are a lot of <dl> tags in the string, but I am looking to match the last <dl>(.?)+</dl> combo that comes before a </div>. The way I've devised to do this is to make sure that t...

Asterisk in eregi

//URL START $urlregex = "^(https?|ftp)\:\/\/"; // USER AND PASS $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // HOSTNAME OR IP $urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // PORT $urlregex .= "(\:[0-9]{2,5})?"; // PATH $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // GET Query $urlregex .= "(\?[a-z+&\$_.-...

Javascript BBCode Parser recognizes only first list element

I have a really simple Javascript BBCode Parser for client-side live preview (don't want to use Ajax for that). The problem ist, this parser only recognizes the first list element: function bbcode_parser(str) { search = new Array( /\[b\](.*?)\[\/b\]/, /\[i\](.*?)\[\/i\]/, /\[img\](.*?)\[\/img\]/, /\[url\="?(.*?...

Regular Expression TCL using procedure

Hey everybody, I am a novice TCL programmer. Here I go - My 1st post with stackoverflow forum. I would like to write a regular expression that matches any & only the strings starts with character A and ends with B. Whatever the characters coming inbetween should be displayed. For instance AXIOMB as an input from the user which starts ...

Building a Hashtag in Javascript without matching Anchor Names, BBCode or Escaped Characters

I would like to convert any instances of a hashtag in a String into a linked URL: #hashtag -> should have "#hashtag" linked. This is a #hashtag -> should have "#hashtag" linked. This is a [url=http://www.mysite.com/#name]named anchor[/url] -> should not be linked. This isn&#39;t a pretty way to use quotes -> should not be linked. Here ...

Regex pattern help (I almost have it, just need a bit of expertise to finish it)

I need to match two cases js/example_directory/example_name.js and js/example_directory/example_name.js?12345 (where 12345 is a digit string of unknown length and the directory can be limitless in depth or not exist at all) I need to capture in both cases everything between js/ and .js and if ? exists capture the digit stri...

actionscript find and convert text to url

I have this script that grabs a twitter feed and displays in a little widget. What I want to do is look at the text for a url and convert that url to a link. public class Main extends MovieClip { private var twitterXML:XML; // This holds the xml data public function Main() { // This is Untold Entertainment's Twi...

Easy Regex question

Trying to replace the first 12 digits of credit card numbers with X's in a predictable blob of text that contains the string: Credit Card Number: 1234123412341234 Here's my PHP function: preg_replace('/Credit Card Number: ([0-9]{12})/','Credit Card Number: XXXXXXXXXXXX',$str); Help? ...