regex

javascript REGex remove single quote in match

var RegTxt = "$f1$='test' AND f2='test2'"; alert(RegTxt.match(/\'[^\']*'/g)) returns the match correctely i:e 'test','test2' but how can i remove the single quote in the match. ...

Can a repeated piece of regular expression create multiple groups? Such as this example...

Hi guys, I'm using RUBY 's regular expression to deal with text such as ${1:aaa|bbbb} ${233:aaa | bbbb | ccc ccccc } ${34: aaa | bbbb | cccccccc |d} ${343: aaa | bbbb | cccccccc |dddddd ddddddddd} ${3443:a aa|bbbb|cccccccc|d} ${353:aa a| b b b b | c c c c c c c c | dddddd} I want to get the trimed...

Help on preg_match pattern

I want to parse a html content that have something like this: <div id="sometext">Lorem<br> <b>Ipsun</b></div><span>content</span><div id="block">lorem2</div> I need to catch just the "Lorem<br> <b>Ipsun</b>" inside the first div. How can I achieve this? Ps: the html inside the first div have multiple lines, its an article. Th...

"User Friendly" .net compatible Regex/Text matching tools?

Currently in our software we provide a hook where we call a DLL built by our clients to parse information out of documents we are processing (the DLL takes in some text (or a file) and returns a list of name/value pairs). e.g. We're given a Word doc or Text file to Archive. We do various things to the file, and call a DLL that will retu...

Python 3: unpack inner lists in list comprehension

I'm running the following code on a list of strings to return a list of its words: words = [re.split('\\s+', line) for line in lines] However, I end up getting something like: [['import', 're', ''], ['', ''], ['def', 'word_count(filename):', ''], ...] As opposed to the desired: ['import', 're', '', '', '', 'def', 'word_count(filen...

How to match a variable list of items separated by commas

I want to turn something like this CS 240, CS 246, ECE 222, ... (more or less); Software Engineering students only into ('CS 240', 'CS 246', 'ECE 222', 'ECE 220') in Python, code that matches a single course looks like >>> re.search('([A-Z]{2,5} \d{3})', 'SE 112').groups() ('SE 112',) I prefer a regular expression only method be...

Why doesn't this simple regex match what I think it should?

I have a data file that looks like the following example. I've added '%' in lieu of \t, the tab control character. 1234:56% Alice Worthington alicew% Jan 1, 2010 10:20:30 AM% Closed% Development Digg: Reddit: Update%% file-one.txt% 1.1% c:/foo/bar/quux Add%% file-two.txt% 2.5.2% c:/foo/bar/quux Remove%% file-thre...

regexIssueTracker not working in CruiseControl.net

I am trying to get an issueUrlBuilder to work in my CruiseControl.NET config, and cannot figure out why they aren't working. The first one I tried is this: <cb:define name="issueTracker"> <issueUrlBuilder type="regexIssueTracker"> <find>^.*Issue (\d*).|\n*$</find> <replace>https://issuetracker/ViewIssue.aspx?ID=$1&lt;/replace...

How does MatchEvaluator works? ( C# regex replace)

This is the input string 23x * y34x2. I want to insert " * " (star surrounded by whitespaces) after every number followed by letter, and after every letter followed by number. So my input string would look like this: 23 * x * y * 34 * x * 2. This is the regex that does the job: @"\d(?=[a-z])|a-z". This is the function that I wrote that i...

Regex to get article ID from url

My url looks like: www.example.com/a-292-some-text-here // 292 www.example.com/a-2-asdfss // 2 www.example.com/a-44-333 // 44 I need a regex to get the 292 from the url. The ID will always be an integer. i am using C#. ...

How do I write this URL in Django?

(r'^/(?P<the_param>[a-zA-z0-9_-]+)/$','myproject.myapp.views.myview'), How can I change this so that "the_param" accepts a URL(encoded) as a parameter? So, I want to pass a URL to it. mydomain.com/http%3A//google.com Edit: Should I remove the regex, like this...and then it would work? (r'^/(?P[*]?)/?$','myproject.myapp.views.myvie...

jQuery Javascript array 'contains' functionality?

I'm trying to use the jQuery $.inArray function to iterate through an array and if there's an element whose text contains a particular keyword, remove that element. $.inArray is only returning the array index though if the element's text is equal to the keyword. For example given the following array named 'tokens': - tokens {...} ...

Regex, match "private function", "public function" or just "function"

I am getting some problems while trying to use this regex: (public +function|private +function|function) +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)} For some reason, $1 and $2 are returning the same value. The target string is: public function messenger(text){ sendMsg(text); } private function sendMsg(text){ ...

javascript RegEx hashtag matching #foo and #foo-fåäö but not http://this.is/no#hashtag

Currently we're using javascript new RegExp('#[^,#=!\s][^,#=!\s]*') (see [1]) and it mostly works, except that it also matches URLs with anchors like http://this.is/no#hashtag and also we'd rather avoid matching foo#bar Some attempts have been made with look-ahead but it doesn't seem to work, or that I just don't get it. With the belo...

Regex is capturing the whole string

I am using the following regex: (public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)} To match the following string: public function messenger(text){ sendMsg(text); } private function sendMsg(text){ alert(text); } (There is no line breaks in the string, they are converted to whitespaces before th...

How do I use regex to do this in Python?

def symbolsReplaceDashes(text): I want to replace all spaces and symbols with hyphens. Because I want to use this with URL. ...

PHP replace string help...

i am designing a site with a comment system and i would like a twitter like reply system. The if the user puts @a_registered_username i would like it to become a link to the user's profile. i think preg_replace is the function needed for this. $ALL_USERS_ROW *['USERNAME'] is the database query array for all the users and ['USERNAME'] ...

PHP regex question : how to match none-ascii letters in latin1_swedish_ci charset?

I have this string : Verbesserungsvorschläge which I think is in German. Now I want to match it with a regex in php. To be more general, I want to match such characters like German which are not 100% in the ASCII set. Thanks. ...

Bash and regex problem : check for tokens entered into a Coke vending machine

Hi all: Here is a "challenge question" I've got from Linux system programming lecture. Any of the following strings will give you a Coke if you kick: L = { aaaa, aab, aba, baa, bb, aaaa"a", aaaa"b", aab"a", … ab"b"a, ba"b"a, ab"bbbbbb"a, ... } The letters shown in wrapped double quotes indicate coins that would have fallen through (...

regular expression to match any string but at least 3 characters

sorry am not a regex expert. but my request is simple, i need to match any string that has at least 3 or more characters that are matching So for instance, we have the string "hello world" and matching it with the following: "he" => false // only 2 characters "hel" => true // 3 characters match found thansk in advance. ...