regex

Can anybody tell me what’s wrong with this code?

I am getting the compile time error. import java.util.regex.Matcher; import java.util.regex.Pattern; class gfile { public static void main(String args[]) { // create a Pattern Pattern p = Pattern.compile("<div class="dinner">(.*?)</div>");//some prob with this line // create a Matcher and use the Matcher.group() method...

ruby regular expression not working with match

text = "I fixed bug #1234 and #7895 " regex = /#(\d*)/ m = regex.match(text) puts m.inspect #<MatchData "#1234" "1234"> In the above case why I am not seeing 7895? What's the correct solution? ...

jQuery: Showing source of one <div> in another with a regular expression

Ok I give up and would really appreciate it if you guys could cast their eye over this for me? I'll try not to ramble. Goal is to have a 'rendered-view' showing 'rendered' HTML (clickable links) and 'source-view' showing the actual HTML of whatever is in the rendered view. When a link is clicked it is made not a link any more and simply...

What's the difference between these two below?

System.out.println(matcher.group(1)); System.out.println(matcher.group()); I like to know what's the difference between the above two codes. I get different outputs. Can anybody elaborate on this? Thanks ...

Quick and easy way to remove "dead" (commented out) code

I'm working with an inherited code base which contains thousands of lines of commented out code. I know the previous coder meant to save all his hard work for posterity rather than simply deleting it but: I will never read it and it just gets in the way. One problem example is that when I perform text searches for certain code segments I...

Is there a free tool that is like a regexp wizard?

Does there exist a free Windows software program that will help you generate regular expressions using a wizard? I'm not exactly sure what I am looking for but I am not looking for a regexp evaluator. What I need is a calculator/wizard to help me learn how reg expressions work, while not knowing all the syntax details (until i have the ...

Javascript Not Parsing Nested Bbcode

I have coded a Javascript bbcode similar to the one I'm using to write this message. It also incorporates a live preview box like the one I see below. The only problem I'm facing at the moment is that some nested bbcode is not parsing. For example: [quote] [quote][/quote] [/quote] Is not parsing correctly. This is my Javascript c...

RegEx URL ReWrite match all in expression unless term exists.

I am currently rewriting a URL, however my RegEx expression is catching a directory I want to be ignored. The rewrite rule is ^people/([A-Za-z0-9\-\_]+)/?$ ...Which catches everything that matches. However, I would like to exclude a directory, People_Search, so for instance... /people/John_Smith ...will forward, but /people/Peop...

regex for PHP preg_replace_callback

Regular expressions is just not my thing. :( I have a string that may contain multiple sub strings such as: [var1="111" var2="222" var3="222" var4="444"] I basically need to replace each occurrence with the the results of a function that gets each variable. $string = '[var1="111" var2="222" var3="333" var4="444"]'; $regex = 'var...

Best way to get back to using the power of lxml after having to use a regex to find something in an html document

I am trying to rip some text out of a large number of html documents (numbers in the hundreds of thousands). The documents are really forms but they are prepared by a very large group of different organizations so there is significant variation in how they create the document. For example, the documents are divided into chapters. I mi...

parsing words in string prefaced by 'password' with regex

a="aaaaaa password: GOD hello world password is G0D hello" match = re.match("^(?:.*(?:password\sis\s|password:\s)([a-zA-Z]*)\s.*)*$",a) print match.groups() i want the output to be ('GOD','G0D') but all i get is ('G0D') i am trying to solve this with Regex only. the amount of times "password" can appear in the text can vary. help wou...

Javascript Regular Expression Question

Hi Guys, I am a Javascript Junkie and wishing to test around some codes. new RegExp("user=" + un + "[\"'\\s>]", "i") what will this actually mean? It was from a site, and it actually works! I especially don't get the [\"'\\s>] part. ...

how to match this Regular Expressions in javascript

Hello i'm trying to find a way to match this problem but i'm LOST i want it to match a math equation that will accept string if: "+-*/%" at anywhere in the string but not in the last character of the input string it accepts float and integers it doesn't accepts letters just numbers and signs any help ? Thanks in advance !! ...

Regex: Is it possible to reference all of the repeats of a capture?

Consider this regex: ^([0-9]+)(?: ([-\+/%\*]) ([0-9]+))+$ In english, it says "a number, followed by one or more of (an operation and another number)". Matched against a subject like 5 + 4 that regex produces $1 = 5, $2 = +, and $3 = 4. Matched against this subject: 5 + 4 * 3, I get $1 = 5, $2 = *, and $3 = 3. In this latter ...

Help in javascript Regular Expressions

i have posted a previous question about Regular Expressions and this is another question it's not duplicate ... sorry for that Hello I really need some help in Regular Expressions, i'm working on a function like var x = 0; function doMath(myVar){ RE = //; // here is the problem if(RE.test(myVar)) eval(x+myVar) else return fals...

What is the best way to achieve `sscanf`-like functionality in perl?

What is the best way to achieve sscanf-like functionality in perl? I am looking now looking at the sscanf module, Which is better, Option-1: Going sscanf way? Option-2: Regex way? [I am a beginner when it comes to Regex] ...

Filter string in C

How can I filter a string in c? I want to remove anything that isn't [a-z0-9_]. int main(int argc, char ** argv) { char* name = argv[1]; // remove anything that isn't [a-z0-9_] printf("%s", name); } ...

Regular Expression for Finding URL (ending with FLV/flv)

I need to get all instances of http://someurl/somefile.flv within a HTML file. Extension must not be case sensitive. I currently use the following simple regular expression that I use in Javascript: var rePattern = new RegExp( "(http://.*.flv)", "gi" ); It has it's flaws though, especially if there is a URL and somewhere...

JavaScript regular expression: can (?=regex) and (?!regex) be used in the middle of a regular expression? Or they must be used at the end of a regular expression?

Hi guys, In JavaScript, can (?=regex) and (?!regex) be used in the middle of a regular expression? Or they must be used at the end of a regular expression? If they can be used in the middle, what's the meaning of it? Great thanks! ...

regex replace - but with a few exceptions.

I have a string containing HTML and I need to replace some words to be links - I do this with the following code; string lNewHTML = Regex.Replace(lOldHTML, "(\bword1\b|\bword2|word3\b)", "<a href=\"page.aspx#$1\">$1</a>", RegexOptions.IgnoreCase); The code works, but I need to include some exceptions to the replace - e.g. I will not r...