Why won't this PHP validate?
<?php $username = "@#*(#(*#($&*#$"; if (preg_match("/^[0-9a-z-A-Z-_@ !]*/", $username)) { echo "true"; } else { echo "false"; } ?> ...
<?php $username = "@#*(#(*#($&*#$"; if (preg_match("/^[0-9a-z-A-Z-_@ !]*/", $username)) { echo "true"; } else { echo "false"; } ?> ...
I need a .Net regular expression that matches anything OTHER than the exact full string match specified. So basically: ^Index$ ... is the only exclusion I care about. Strings can start with, finish with or contain "Index", but not match exactly. My brain doesn't seem to be working today and I'm failing to work this one out. EDIT The...
Hey folks. Regexs make me cry, so, I came here for help. I'm looking for some tips on Find & Replace in Panic's Coda. I know the F&R is pretty advance but I'm just looking for the best way to do this. I'm trying to rewrite a 'template engine' (very basic) I have going on with a webapp I'm coding in PHP (CodeIgniter). Currently I'm ca...
I am using a regular expression in javascript and want to do server side validation as well with the same regular expression. Do i need to modify it to make it compatible or will it run as it is. How to use PHP regular expresion. Please provide a small example. Thanks in Advance EDIT For Email Validation var pattern = new RegExp(/^(...
i want to match something like aaaa, aaaad, adjjjjk. Something like this ([a-z])\1+ was used to match the repeated characters but i am not able to figure this out for 4 letters. ...
page contents: aa<b>1;2'3</b>hh<b>aaa</b>.. .<b>bbb</b> blabla.. i want to get result: 1;2'3aaabbb match tag is <b> and </b> how to write this regex using javascript? thanks! ...
I have a file that is similar to this: <many lines of stuff> SUMMARY: <some lines of stuff> END OF SUMMARY I want to extract just the stuff between SUMMARY and END OF SUMMARY. I suspect I can do this with sed but I am not sure how. I know I can modify the stuff in between with this: sed "/SUMMARY/,/END OF SUMMARY/ s/replace/with/" ...
Hi, how can I write regex which is matched for any string with any size? ...
I have a table in SQL Server 2005 with hundreds of rows with HTML content. Some of the content has HTML like: <span class=heading-2>Directions</span> where "Directions" changes depending on page name. I need to change all the <span class=heading-2> and </span> tags to <h2> and </h2> tags. I wrote this query to do content changes in ...
Hi - I'm looking for a good example of using Regular Expressions in PHP to "reverse engineer" a form letter (with a known format, of course) that has been pasted into a multiline textbox and sent to a script for processing. So, for example, let's assume this is the original plain-text input (taken from a USDA press release): WASHING...
I have a string that contains html. I want to get all href value from hyperlinks using C#. Target String <a href="~/abc/cde" rel="new">Link1</a> <a href="~/abc/ghq">Link2</a> I want to get values "~/abc/cde" and "~/abc/ghq" ...
I'm trying to change instances of the following line: URL: http://www.google.com/?s= test to URL: <a href="http://www.google.com/?s=%20test">http://www.google.com/?s= test</a> note that the anchor url is url encoded I've managed to get parse the URL part using a very simple regex: <cfset getFacts.fact_details = REReplace(getFa...
I want to extract a substring matching a pattern and save it to a file. An example string: Apr 12 19:24:17 PC_NMG kernel: sd 11:0:0:0: [sdf] Attached SCSI removable disk I want to extract the part between the brackets, in this case [sdf]. I tried to do something like grep -e '[$subtext]' to save the text in the brackets to a variable...
Using regexp with tokens on cell array of strings I've got cell array of cells. Here is simplified example: S = {'string 1';'string 2';'string 3'}; res = regexp(S,'(\d)','tokens') res = {1x1 cell} {1x1 cell} {1x1 cell} res{2}{1} ans = '2' I know I have only one match per cell string in S. How I can convert this outp...
How can I use Membership.GeneratePassword to return a password that ONLY contains alpha or numeric characters? The default method will only guarantee a minimum and not a maximum number of non alphanumeric passwords. I have the solution already but thought I'd share for future visitors. .. Answer coming up. ...
Hi, I'm trying to preg_replace charset=blablabla; and charset=blablabla" with charset=utf-8; and charset=utf-8". Please see ; = and " characters, and of course searched string can be lower/uppercase. Can you help me? ...
I need help converting eregi_replace to preg_replace (since in PHP5 it's depreciated): function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', ...
I have the following data: a b c d FROM:<uniquepattern1> e f g h TO:<uniquepattern2> i j k l FROM:<uniquepattern1> m n o p TO:<uniquepattern3> q r s t FROM:<uniquepattern4> u v w x TO:<uniquepattern5> I would like a regex query that can find the contents of TO: when FROM:<uniquepattern1> is encountered, so the results would be uniquep...
I am trying use the following regular expression to extract domain name from a text, but it just produce nothing, what's wrong with it? I don't know if this is suitable to ask this "fix code" question, maybe I should read more. I just want to save some time. Thanks pat_url = re.compile(r''' (?:https?://)* (?:[...
Yep - another noob regex query, which I can't seem to get. I'm trying to get all matches for the string foo.mydomain.com/ or foo.mydomain.com:1234/ or foo.mydomain.com:<random port>/ but any other paths do not match, ie. foo.mydomain.com/bar or foo.mydomain.com/bar/pewpew I tried to use: foo.mydomain.com(.*)/$ (which starts with anythi...