regex

remove sms unsupported characters

is there any preg or str_replace that can help me remove characters from a string that are not supported on sms in phones. Now accented characters are shown as yy in sms. ...

Can I make a SQL Server 2005 Table Column accept only letters and numbers ?

When we have a column that will store a username that will only accept letters and numbers we always do validation on this input field using javascript or even server validation from code .. but i want to know if is there any way that can allow me make this validation on the Table column itself even some one try to enter data from any pl...

Modify jQuery Highlight? Javascript Regex

How can I modify jquery highlight such that it doesn't find matches that appear directly before or after an alpha character? In other words, how do I prevent a match mid-word? /* highlight v3 Highlights arbitrary terms. <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html&gt; ...

Selectively search and replace certain lines using a regular expression

I have a file containing a lot of SQL statements, such as: CREATE TABLE "USER" ( "ID" INTEGER PRIMARY KEY, "NAME" CHARACTER VARYING(50) NOT NULL, "AGE" INTEGER NOT NULL ); COPY "USER" (id, name, age) FROM stdin; 1 Skywalker 19 2 Kenobi 57 I want the column names in the COPY statements to be uppercased and quote...

Javascript replace using regexp

<input type="text" value="[tabelas][something][oas]" id="allInput"> <script type="text/javascript"> allInput = document.getElementById('allInput'); var nivel = new Array('tabelas', 'produto'); for (var i =0; i < nivel.length ; i++ ) { alert(" oi => " + allInput.value + " <-- " + nivel[i]) ; var re = new RegExp("^\[" + nivel[i] + "\...

Regular Expression

I cannot manage to get a working regular expression (for use in ASP.NET Validataor) for the following criteria: I want all chars from A-Z a-z 0-9 I don't want the Enter key I have the expression: [\w\s,.-/]*[^\n] but that doesn't work. Can anyone give me a hint? ...

replace capturing group

Hi, If I have a regex with a capturing group, e.g. foo(_+f). If I match this against a string and want to replace the first capturing group in all matches with baz so that foo___f blah foo________f is converted to: foobaz blah foobaz There doesn't appear to be any easy way to do this using the standard libraries. If I use Matcher...

Regex: Comma delimited integers

Hi Guys, I'm trying to create a regex that accept: An empty string, a single integer or multiple integers separated by a comma but can have no starting and ending comma. I managed to find this, but I cannot undertsand how to remove the digit limit ^\d{1,10}([,]\d{10})*$ ...

Replace {tag} with a value or completely remove {any-tag}

I've designed a multilingual web site and some values in database have a tag which will be replaced with it's language value, remove tags brackets ( in case {} ) or removed completely. There are two cases: Remove brackets: value {mm} >> value mm Remove completely: value {mm} >> value Also {tag} could be any length and can contain...

How do I match complete XML objects in a string?

I'm attempting to find complete XML objects in a string. They have been placed in the string by an XmlSerializer, but may or may not be complete. I've toyed with the idea of using a regular expression, because it seems like the kind of thing they were built for, except for the fact that I'm trying to parse XML. I'm trying to find comple...

Convert to lowercase in a mod_rewrite rule.

I would like URLs like server.com/foo to be case-insensitive. But server.com/foo actually gets mod_rewrite'd to server.com/somedir/foo (Assume that all the files in "somedir" are lower case.) So the question is, how to accomplish a mod_rewrite like the following: RewriteRule ^([^/]+)/?$ somedir/convert_to_lowercase($1) PS: Here's ...

Regex for url domain

How do i match from these urls: http://foo.bar.com http://bar.com foo.bar from the first link and bar from the second link using one single regex? ...

How do I replace multiple newlines with a single one with Perl's Regular Expressions?

I've got a document containing empty lines (\n\n). They can be removed with sed: echo $'a\n\nb'|sed -e '/^$/d' But how do I do that with an ordinary regular expression in perl? Anything like the following just shows no result at all. echo $'a\n\nb'|perl -p -e 's/\n\n/\n/s' ...

smaller date regex

I have a regex used to validate dates: ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$ Works really well, but I am...

PHP: preg_replace() with pattern modifier e - strange behaviour in evalution result seems to ignore back references

Consider the following situation: I want to replace links in a string, specifically I want to add a "search engine" link next to it. Think: Link Title (S), where as S will link to Google with "Link Title" as search term. I've copied a real life example string ($content) in the code so you can reproduce this 1:1 in PHP code. // PCRE cas...

PHP PCRE expression problem - get digits of a string

Hi, I need a regex expression (PCRE) to match a integer number inside a string, being the string like : image89.jpg I've tried many options without success. I'm using preg_replace() by the way My last attempt : preg_replace('(\d+)', '$1', 'image89.jpg'); ...

Regular expressions in java

String s= "(See <a href=\"/wiki/Grass_fed_beef\" title=\"Grass fed beef\" " + "class=\"mw-redirect\">grass fed beef.) They have been used for " + "<a href=\"/wiki/Paper\" title=\"Paper\">paper-making since " + "2400 BC or before."; In the string above I have inter-mixed html with text. Well the requiremen...

Python matching some characters into a string

Hi All I'm trying to extract/match data from a string using regular expression but I don't seem to get it. I wan't to extract from the following string the i386 (The text between the last - and .iso): /xubuntu/daily/current/lucid-alternate-i386.iso This should also work in case of: /xubuntu/daily/current/lucid-alternate-amd64.iso ...

Preg_replace regex, newlines, connection resets

I have mixed html, custom code, and regular text I need to examine and change frequently on several, long wiki pages. I'm working with a proprietary wiki-like application and have no control over how the application functions or validates user input. The layout of pages that users add must follow a very specific standard layout and alw...

regex search a mysql text column

Okay, I thought my head hurt with regular regex, but I can't seem to find what I'm looking for with regexp in mysql. I'm trying to look for situations in news articles where a Textile-formatted url has not ended with a slash so: "Catherine Zeta-Jones":/cr/catherinezeta-jones/ visited stack overflow is ok but "Catherine Zeta-Jones":/cr/...