regex

how to replace all using regexp (javascript)

var text = "'Hello'World'''"; how to replace all ' and Hello and World to ' result = "'''''''" ...

how to get style="i want the css code" using regexp (javascript)

var text = '..<anything><anything style="color:red;">hello</anything><anything style="color:blue; font-size:1em;">hello</anything></anything>...'; or var text = "..<anything><anything style='color:red;'>hello</anything><anything style='color:blue; font-size:1em;'>hello</anything></anything>..."; result: array[0] = "color:red;"; arr...

Is there a way to match a set of groups in any order in a regex?

Title says it all. I looked through the related questions, there were quite a few but I don't think any answered this question. I am very new to Regex but I'm trying to get better so bear with me please. I am trying to match several groups in a string, but in any order. Is this something I should be using Regex for? If so, how? If it mat...

Replace string by excluding some strings in Java

How can I replace following string in Java: Sports videos (From 2002 To 2003) here. TO Sports videos 2002 2003 here. I have use code but it remove the whole string i.e. I am getting this ouput: Sports videos here. String pattern= "\\((From)(?:\\s*\\d*\\s*)(To)(?:\\s*\\d*\\s*)\\)"; String testStr = "Sports videos (From 2002 ...

avoid regex [python]

hi, I'd like to know if it's a good idea avoid regex. actually I have avoided it in any case and some peoples has been giving me advice that i shouldn't avoid it, since if you know what means every thing like: [] '|' \A \B \d \D \W \w \S \Z $ * ? ... it would be easy to read, right? but i fell like avoiding regex i woul...

Mysql Regex Problem

I want to find only those rows whose column 'col' c doesn't contain characters from a-1. So I don't know how to write script. I've succeed to write script which is opposite to this. Thanks in Advance. select * from tbl_comment c where c.`message` regexp '{a-z}'; I need the script which will be opposite to this. I've tried "not re...

convert regular expression from php to asp classic

function cleanURL($string) { $url = str_replace("'", '', $string); $url = str_replace('%20', ' ', $url); $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url); $url = trim($url, "-"); $url = strtolower($url); $url = preg_replace('~[^-a-z0-9_]+~', '', $url); return $url; } $regex=cleanURL("$title"); how to...

How do you search and replace anything beyond an equal sign

We have a property file (name, value key pairs) and would like to replace everything beyond the equal sign = with nothing. How do I do that? label.one=One label.two=Two Post replacement, I would want label.one= label.two= ...

Why does my JavaScript regex not work?

I don't understand why, but this code gives me a JavaScript error: <script type="text/javascript"> String.prototype.format = function(values) { var result = this; for (var i = 0, len = values.length; i < len; i++) { result = result.replace(new RegExp("{" + i + "}", "g"), values[i]); } return result; }; alert("H...

How can I replace a regex substring match in Javascript?

var str = 'asd-0.testing'; var regex = /asd-(\d)\.\w+/; str.replace(regex, 1); That replaces the entire string str with 1. I want it to replace the matched substring instead of the whole string. Is this possible in Javascript? ...

Regular expression greater than and less than

Hi, This expression is to check number > 1 ^[1-9]+[0-9]*$ what is the expression to check if it's greater than a given value, say "99" ? what about a value less than, 99? Update: I'm using ASP.NET validation control. Thanks. ...

php + vim - बंगलौर (Bangalore) has a break before the last character र

I used http://translate.google.com/#en|hi|Bangalore to get the Hindi for Bangalore and बंगलौर. But when I pasted it in vim there is a break before the last character र. I am using preg_replace with the regex pattern /[^\p{L}\p{Nd}\p{Mn}_]/u for matching words. But this is treating the last character as a separate word. This is my input...

regular expressions to strip h3 tag and leave the content

im looking for a regex to strip the h3 tag and only the content should remain eg. <h3 id="123">my h3 tag</h3> i need to strip the tag and be left with my h3 tag im currently have reMatchNoCase("(<h3)(.*?)(</h3>)",i) this was parsed from many other parts of a string, not i need it cleaned to the content thanks ...

Regex to validate email is failing if 2 "@" are provided.

Hi, We have followed the regex for validating RFC 2822 standard. The function is as follows: int isValidEmail(const char *email_id) { /* Regular expression to validate email */ const char *reg_exp = "[a-z0-9!#$%&'*+-/=?^_`{|}~]+(\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9]([a-z0-9-]*[a-...

How to check for uppercase alphabets in an input string, using jQuery

Hi, I am using following code snippet, but its not working :-( //First four characters of input Text should be ALPHABATES (Letters) if (($("#txtId").val()).length >= 4) { var firstFourChars = $("#txtId").val().substring(0, 4); var pattern = new RegExp('[^A-Z]'); if (firstFourChars.match(pattern)) ...

RegEx Whitelist Problem

I'm a little confused. I am running all my inputs through a basic sanitize function I write to only allow certain characters, but characters such as [] are still being allowed. function sanitize($input) { $pattern = "/[^a-zA-z0-9_-]/"; $filtered = preg_replace($pattern, "", $input); return $filtered;} Any idea why it's doing that? ...

regular expression for matching date in Perl

I want to match dates that have the following format: 2010-08-27 02:11:36 i.e. yyyy-mm-dd hh:mm:ss. Right now I am not very particular about the date being actually feasible, but just that it is in the correct format. Possible formats that should match are (for this example) 2010 2010-08 2010-08-27 2010-08-27 02 2010-08-27 02:11 20...

Javascript Conditional Regex with Processing

Hi All, While converting an old code, I encountered the following problem. Given an HTML string, <Font face="Arial" size="21" color="#000000"> THIS IS SIZE 21 </Font> I want to subtract a factor "X" from the size "21" in the output string by using Regex? So the new string be <Font face="Arial" size="(21-X)" co...

Change a string based on a pattern

Hi all, I want to change a string in PHP by deleting the first and the last char but ONLY IF they are equal. Let me give some examples: ' abc ' should become 'abc' 'abc a' should become 'bc ' ' abc a' should not change How do I do it? Thanks for the help, the regex based solution works. ...

PHP Get text between multiple <h1>...</h1> tags

Hello! I have a page with multiple H1 headings followed by text and so on. Example: <h1>Title 1</h1>Some text here <h1>Title 2</h1>Some moretext here <h1>Title 3</h1>Even more text here etc What I want to do is create an array of elements, that is explode the html using as separator <h1>ANY TEXT</h1> above that I have in an $output ...