regex

Shell: How to replace something of a text with the saved variable value

I saved a value by shell command: For example: timeoutvalue=`echo "timeout=2.0"` And I have to grep the value of timeout from another text, and replace it with this timeoutvalue. For example, the text is egtest: <host ip="255.255.255.0" name="testhost" description="hostfortest" connection="xmlrpc" timeout=4.0/> I want to grep the v...

What does this regex mean in PHP?

/(?![a-z]+:)/ Anyone knows? ...

Can this be done without a regular expression?

I've got a string split, using a regular expression. Regex.Split(str, @"\s"); What does this convert to without regex? reason being I'm porting this to PHP and an SQL function. Unless you can show me the PHP code for the same... ...

Movable Type: How to replace " with &quot;

Hi, I am trying to replace only " with &quot; within EntryBody I tried <mt:entrybody replace=""","&quot;"> but this seems to not work. Version is MT5.02 and I don't want to use <mt:entrybody encode_html="1"> What I am trying to do is import all entires using CSV(comma separated) format(clients request) and " (quotation mark) inside E...

How to write this Regex

HTML: <dt> <a href="#profile-experience" >Past</a> </dt> <dd> <ul class="past"> <li> President, CEO &amp; Founder <span class="at">at</span> China Connection </li> <li> Professional Speaker and Trainer <span class="at">at</span> Edgemont Enterprises </li> <li> ...

Regex: Help with extracting a filed from the text and replace the value of the field

I have to extract a parameter from a configuration file, and replace its values with another given value. The config file is: <host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/> I have to replace the value of xmldefaulttimeout=...

How to write such a regex in PHP?

$contents = 'url("/test/what)'; echo preg_replace('/url\(([\'"]?)(?!(?:[a-z]+:)|\/|[\'"]\/)/i', 'url(\1'. '/prefix' . '\2', $contents); I want to append /prefix to those urls that didn't use absolute path(start with /), the above works, but is pretty ugly. Is there a more elegant solution? ...

Removing nested bbcode (quotes) in PHP

Hello, I'm trying to remove nested quoting from my bulletin board, but I'm having some issues. Example input: [quote author=personX link=topic=12.msg1910#msg1910 date=1282745641] [quote author=PersonY link=topic=12.msg1795#msg1795 date=1282727068] The message in the original quote [/quote] A second message quoting the firs...

How to drop some characters with Regex in vs ?

I have a sql table and I have a column which includes data such as: B757-34-11-00-I-1, A300-223100-0503-1 etc. A300-223100-0503-1 -> 223100-0503-1 B757-34-11-00-I-1 -> 34-11-00-I-1 How can i do that with regex? I need two kinds of solutions: sql and C#. how can I do that with sql query in SQL and C# i need drop charater as far...

Regular expression not working when put in an object

Hi! I'm trying to store regexes in a database but they're not working when used in a .sub(), even though the same regex works when used directly in .sub() as a string. regex = Class.object.field // Class.object is an active record containing "\w*\s\/\s" mystring = "first / second" mystring.sub(/#{regex}/, '') // => nil mystring.sub(...

regular expression: find spaces (tabs/space) but not newlines

how can i have a regular expression that tests for spaces or tabs but not newlines. i tried \s but found out that it tests for newlines too. i use C#/WPF but it shouldn't matter ...

Mapping String contents key/value pairs to a HashMap

Hello guys, I'm trying to establish some way of mapping a String document to a HashMap as follows: the String contains key/value pair $key1=value1 $key2=value2 value21 value22 $key3=value3 what I want to end up with is: key1, value1 key2, value2 value21\nvalue22 key3, value3 Is there a pattern I can use for this? It looks like an...

Count no. of words using Regular expressions in java

How to count the number of times each word appear in a String in Java using Regular Expression? ...

What is wrong with this regex?

i need the following - if i have a sentence $str = "i like programming very much"; and i search for a word $word = "r"; i expect it to return the sentence "i like programing very much" I wrote the following regex for it, but it sometimes doesn't work. $str = preg_replace("/([^\s{".preg_quote($word)."}]*?)(".preg_quote($word)...

Regex for removing part of a line if it is preceded by some word in Java

There's a properties language bundle file: label.username=Username: label.tooltip_html=Please enter your username.</center></html> label.password=Password: label.tooltip_html=Please enter your password.</center></html> How to match all lines that have both "_html" and "</center></html>" in that order and replace them with the same lin...

Regex to select span ID.

Hi, Kindly help me know the regex to select only span id for a given span markup. I'm trying to do it from inside c#. My input is like . And I want as an output only >> id="x8x8d9s8" << Currently I'm trying to achieve above as follows but no luck, unfortunately ... string innerPattern = @"(id=)\""|&quot;|(.)*\""|&quot;|"; Please no...

match all except some word

i'm looking for a way, to match all except the some word. please tell me how i must wrote it? when i wrote $str = "i am a programmer"; $word = "am"; preg_match_all("/[^($word)]/", $str, $matched);// it do the same, if i when i wrote preg_match_all("/[^$word]/", $str, $matched); i also tried preg_match_all("/[^{$word}]/", $str, $mat...

Regex for html parsing in php

Possible Duplicate: RegEx match open tags except XHTML self-contained tags Hello, i m stuck in weird regex problem, i m parsing some html table in php regex i m using : <td[^>]*>(h.*?)</td> <td>other data</td> <td>other data</td><td>Data_needed</td> <td>--</td> but its matching all other data too now i want to match it t...

Find URL inside NSString (BBCode) using RegexKitLite

HI, I have a NSString that cotains a lot of text. Inside the text is a iTunes URL. The URL is masked with BBCode. How can I extract the plain URL? Sorry, but my regex skills are really bad. The text: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam ...

Optimized regex for N words around a given word (UTF-8)

I'm trying to find an optimized regex to return the N words (if available) around another one to build a summary. The string is in UTF-8, so the definition of "words" is larger than just [a-z]. The string that serves as the reference word could be in the middle of a word or not directly surrounded by spaces. I've already got the followi...