regex

Javascript RegEx Question

Hello, Suppose I have this: $('ul.child').slideUp('slow'); What would be the regex to find 'ul.child' and 'slow' (including quotes) in the above expression. ...

replace special characters in string in java

I want to know how to replace the string in Java. E.g. String a = "adf�sdf"; How can I replace and avoid special characters? ...

VBScript + Regular Expressions

Dim sString sString = "John;Mary;Anne;Adam;Bill;Ester" Is there a regex I can use to retrieve the following from the above list: John (; at the end of the name) Anne (; at the beginning and end) Ester (; at the beginning) I am currently using the following regex for each: 1. Joh.* 2. .*An.* 3. .*st.* But, the above retrieves ...

Using JavaScript regex to strip substring that contains parentheses

I have a string called myString that contains some part the end that I do not want: var myString = 'The sentence is good up to here foo (bar1 bar2)'; var toBeRemoved = 'foo (bar1 bar2)'; How can I use best JavaScript regex to remove the part I don't want. The method replace() seems to have a problem with the parentheses. Edit: I d...

Perl, regex, extract data from a line

Im trying to extract part of a line with perl use strict; use warnings; # Set path for my.txt and extract datadir my @myfile = "C:\backups\MySQL\my.txt"; my @datadir = ""; open READMYFILE, @myfile or die "Error, my.txt not found.\n"; while (<READMYFILE>) { # Read file and extract DataDir path if (/C:\backups/gi) ...

How to get boolean results of regex match in Ant?

Is there a way in Ant to just use regex to search through a file for a line and get a boolean result if there is a match or not? I want to look through a log file for an error line. If the error line exists, I want to perform some additional steps. In the worst case, I could use the Script tag but would like to avoid it if Ant has a w...

Regex - Ignore lines with matching text

I need the RegEx command to get all the lines which DO NOT have the job name containing "filewatch". Any help will be greatly appreciated! Thanks. STATUS: FAILURE JOB: i3-imds-dcp-pd-bo1-05-ftpfilewatcher STATUS: FAILURE JOB: i3-cur-atmrec-pd-TD_FTP_Forecast_File_Del_M_Su ALARM: JOBFAILURE JOB: i3-cur-atmrec-pd-TD_...

groovy: how to escape "(" regex etc in textarea?

I have some text area field in my grails application. I got the following errors: .PatternSyntaxException: Unmatched closing ')' near index 36 Name: note: 1) data listing .... how could i escape the regular expressions in the text area field? thanks. ...

Sed not reconizing \t instead it is treating it as 't' why?

sed "s/\(.*\)/\t\1/" $filename > $sedTmpFile && mv $sedTmpFile $filename I am expecting this sed script to insert a tab in font of every line in $filename however it is not. For some reason it is inserting a t instead.. Strange.. ...

Remove HTML tags and comments from a string in C#?

How do I remove everything beginning in '<' and ending in '>' from a string in C#. I know it can be done with regex but I'm not very good with it. ...

extract variables from an expression using javascript regexp

For example, here is a string representing an expression: var str = 'total = sum(price * qty) * 1.09875'; I want to extract variables (i.e., 'total', 'price' and 'qty' but not 'sum' since 'sum' is a function name) from this expression. What is the regexp pattern in javascript? Variable name consists of letters, digits, or the undersco...

Regex to find A and not B on a line

I'm looking for a regex to search my python program to find all lines where foo, but not bar, is passed into a method as a keyword argument. I'm playing around with lookahead and lookbehind assertions, but not having much luck. Any help? Thanks ...

PHP regex help -- reverse search?

So, I have a regex that searches for HTML tags and modifies them slightly. It's working great, but I need to do something special with the last closing HTML tag I find. Not sure of the best way to do this. I'm thinking some sort of reverse reg ex, but haven't found a way to do that. Here's my code so far: $html = '<div id="test"><p styl...

regex to parse csv

I'm looking for a regex that will parse a line at a time from a csv file. basically, what string.readline() does, but it will allow line breaks if they are within double quotes. or is there an easier way to do this? ...

[PHP]RegEx help with a string

So I have a random of strings and I need to parse them, let's take an example: This string - DeleteMe please and some other text So I want to find DDeleteMe please and some other text and remove it, because all I need is This string Best Regards, ...

How to match filetype with regular expression?

Hi. I'm stuck trying to get a regex to match a filetype in a sorting script. Dir.foreach(savedirs[0]) do |x| puts "Matching " + x + " against filetypes." case x when x.match(/^.*\.exe$/i) then puts x when x.match(/\.jpe?g$/) then FileUtils.move(x, sortpath[".exe"], :verbose => true) when x =~ /\.jpg$/ then FileUtils.move(x, so...

Python regex look-behind requires fixed-width pattern

Hi When trying to extract the title of a html-page I have always used the following regex: (?<=<title.*>)([\s\S]*)(?=</title>) Which will extract everything between the tags in a document and ignore the tags themselves. However, when trying to use this regex in Python it raises the following Exception: Traceback (most recent call l...

Changing input name attribute

Hello! I have some hidden inputs like this <input name="exam.normals[1].blahblah" ..../> I would like somehow to replace the [1] with a number that I want (index). I aint lazy but I am trying to find a good way to do this... A solution would be a replace of exam.normals[1] with exam.normals[+ index +] but I should substr the whole s...

Convert tags to html entities

Hello, Is it possible to convert html tags to html entities using javascript/jquery using any way possible such as regex or some other way. If yes, then how? Example: <div> should be converted to &lt;div&gt; Note: I am not talking about server-side languages. ...

Regular expressions in findstr

I'm doing a little string validation with findstr and its /r flag to allow for regular expressions. In particular I'd like to validate integers. The regex ^[0-9][0-9]*$ worked fine for non-negative numbers but since I now support negative numbers as well I tried ^([1-9][0-9]*|0|-[1-9][0-9]*)$ for either positive or negative intege...