regex

modify sql file on using command line on unix

I have a .sql file that needs a little tweaking, speficially: [xx_blah] any pattern like the above needs to be changed to: [Blah] i.e. remove the xx_prefix and upper case the next character. any tips? ...

can I do a regex search/replace in vs.net?

In vs.net, I want to search for all occurances of [someWord] in my .sql file, and replace it with [SomeWord] Is this possible? (notice the uppercasing of the first character in the result) ...

remove specific rules out of inline CSS

hi guys, i'd like to remove some specific css rules (i.e. width and height) out of inline style attributes. so i want to transform the following: <table id="foo" style="border:1px #000 solid; width: 100px; height: 100px;"> into <table id="foo" style="border:1px #000 solid"> is there a handy regex that solves my problem? thank yo...

Regular Expression to find all Email Matches help for C# application

I have an application where I need to parse a string to find all the e-mail addresses in a that string. I am not a regular espression guru by any means and not sure what the differnce is between some expressions. I have found 2 expressions that, apprently, will match all of the e-mail addresses in a string. I cannot get either to work in...

regex to remove prefix and another to upper case the first letter

I need to do things in 2 steps here: modify all occurences of [xx_someText] with [someText] modify all occurences of [someText] with [SomeText] I need this in 2 regex because some table names are not prefixed with xx_ I am on a windows machine. I have access to unix, BUT I am using the GIT bash utility which seems to have sed and...

Find answer to string equation without using eval()

I need a way of taking an equation given as a string and finding it's mathematical answer, the big caveat is that I can't use eval(). I know the equation will only ever contain numbers, the four mathematical operators (i.e. * / + -) and parentheses, it may or may not have spaces in the string. Here's a couple of examples. 4 * 4 4+6/3 (...

grouping in front of positive lookbehind not matching

Hi Take the following code: $target = 'NAME FUNC LPAREN P COMMA P COMMA P RPAREN'; //$target = 'NAME FUNC LPAREN P RPAREN'; //$target = 'NAME FUNC LPAREN RPAREN'; $pattern = '/(?P<ruleName>NAME )?(?P<funcName>FUNC )?(?:(?<=LPAREN)(?: (?P<arg1>P))|(?P<args>P)(?=(?: RPAREN)|(?: COMMA)))/'; preg_match_all($pattern,$target,$matches,PREG_O...

Running a regex in GIT Bash, my file now has funny characters in it.

I ran this regex in GIT BASH (I am on a windows machine, and I have GIT installed). perl -pe 's/\[(?:xx_)?([^]]+)\]/\[\u$1\]/g' The file now looks as if it is written in Chinese (it is a .sql schema file). example: 嵛 嬀] IDENTITY(1,1) NOT NULL, Is there some encoding issue going on? ...

Replacing all non-alphanumeric characters with empty strings

I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", ""); ...

preg_grep on a larger string

Hi! I need to use preg_reg on some string with content from a html file. $file = file_get_contents($path); $html_array = explode(' ', $file); The problem is that the array looks sometimes like this: [77]=> string(35) "<div> </div> <br> {{testto}} <br>" I have tried to put in some whitespaces there.. :P Won't work.. :/ L...

regex to replace all occurances text, uppercase first character in a file using c#

I want to rename all my sql tables, having the first character upper case. So: [blahField] [int] NOT NULL, should be converted to: [BlahField] [int] NOT NULL, (it doesn't matter if [int] becomes [Int]. I am just using a c# console application to do this quickly. ...

The Best Way of Trimming Spaces in a String

How do I trim spaces inside leaving only one space taking consideration of performance? Input: AA BB Output: AA BB Input: A A Output: A A ...

Extracting URLs from a text document using Java + Regular Expressions

I'm trying to create a regular expression to extract URLs from text documents using Java, but thus far I've been unsuccessful. The two cases I'm looking to capture are listed below: URLs that start with http:// URLs that start with www. (Missing the protocol from the front) along with the query string parameters. Thanks! I wish I rea...

Regex pattern help wanted

The raw string is like this: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 MS Shell Dlg 2;}} \viewkind4\uc1\pard\sb100\sa100\f0\fs24\u30340?\u27494?\u35013?\u20998?\u23376?\u65292?23\u26085?\u22312?\u33778?\u24459?\u23486?\u21335?\u37096?\u30340?\u39532?\u20140?\par \pard\f1...

Apache rewriteRule for root directory

I used to have the following rule in my .htaccess while building a website: RewriteRule ^test/(.*) cgi-bin/router.py?request=$1 [NC] Whenever the user goes to mysite.com/test/something they get redirected to cgi-bin/router.py?request=something. This worked very well. I have now finished the site and want to 'turn it on'. However simpl...

(ruby) help matching my regular expression

I am trying to match the value of the following HTML snippet: <input name="example" type="hidden" value="matchTextHere" /> with the following: x = response.match(/<input name="example" type="hidden" value="^.+$" \/>/)[0] why is this not working? it doesn't match 'matchTextHere' edit: when i use: x = response.match(/<input name="...

Regular Expression Tools

Possible Duplicate: Regex Testing Tools What sorts of tools do other programmers use when creating regular expressions? I use The Regex Coach but it is sometimes a little slow when dealing with larger expressions. ...

Mod Rewrite complete befuzzlement

Here is my .htaccess file Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule subpage\?sid /index.php [R=301,L,NC] My request is http://example.com/subpage?sid It keeps returning 404 Not Found, rather than redirecting to index.php I have tried not escaping the ? and changing the request to http://example.com/subpage\...

Extremely Easy Regex Replace question...

Here is the text I have Remediation2009November Remediation2009December Here is the regex I developed to find them Remediation2009(November|December) What I am not sure about is how to develop a regex so that when I perform the replace I can simply append a word to the end of my matches Remediation2009NovemberCompany2 Remediation200...

Preg Match Empty String

How to preg_match for an null (empty) string?? I need something like: /([0-9]|[NULL STRING])/ ...