Search Results

Search found 9872 results on 395 pages for 'preg replace callback'.

Page 55/395 | < Previous Page | 51 52 53 54 55 56 57 58 59 60 61 62  | Next Page >

  • With PHP preg_match_all, get value of href

    - by Jeremy Dicaire
    Hi, I don'T really understabd how regular expressions works even after I read this tutorial http://www.webcheatsheet.com/php/regular_expressions.php Here is what I need to find: And it should return: http://link Here is what I tried: $find = preg_match_all('/<link type="text/html" rel="alternate" href=".*',$file,$patterns2); You can laught :) Thanks in advance for your help and your time :)

    Read the article

  • delete multi-line block of text with internal flag in povray file

    - by Sibo Lin
    I have a pov-ray file, which defines a lot of cylinders and spheres. Sometimes these shapes are defined to have "color@", which makes the povray unrenderable. One solution I've found is to delete the offending cylinders and spheres. So a file that contains this text cylinder { < -0.17623, 0.24511, -0.27947>, < -0.15220, 0.22658, -0.26472>, 0.00716 texture { colorO } } sphere { < -0.00950, 0.00357, 0.00227>, 0.00716 texture { color@ } } cylinder { < -0.00950, 0.00357, 0.00227>, < 0.00327, 0.00169, 0.00108>, 0.00716 texture { color@ } } sphere { < 0.15373, 0.00601, 0.18223>, 0.00716 texture { colorO } } would turn into this text cylinder { < -0.17623, 0.24511, -0.27947>, < -0.15220, 0.22658, -0.26472>, 0.00716 texture { colorO } } sphere { < 0.15373, 0.00601, 0.18223>, 0.00716 texture { colorO } } Is there some way to do this replacement with a shell script? Preferably in tcsh. Thanks!

    Read the article

  • replacing text within quotes until next quote

    - by Jordan Trainor
    String input = "helloj\"iojgeio\r\ngsk\\"jopri\"gj\r\negjoijisgoe\"joijsofeij\"\"\"ojgsoij\""; This is my current code that works but iv added some code that has to run before this which makes some '"' split onto another line thus making the code below obsolute unless under certain cirumstances the '"' is not put onto the next line. firstQuote = input.IndexOf("\""); lastQuote = input.LastIndexOf("\""); input = input.Substring(0, firstQuote) + "<span>quote" + input.Substring(firstQuote + 1, lastQuote - (firstQuote + 1) + "quote</span>" + input.Substring(lastQuote + 1, lines.Length - (lastQuote + 1); How could I change the input string from input = "helloj\"iojgeio\r\ngsk\\"jopri\"gj\r\negjoijisgoe\"joijsofeij\"\"\"ojgsoij\""; to input = "helloj(<span>quoteiojgeio\r\ngsk\\"jopriquote</span>gj\r\negjoijisgoe<span>quotejoijsofeijquote</span>quote<span>quote</span>ojgsoij<span>quote</span>";

    Read the article

  • Convert inline image tags like [image:123:title:size] into HTML img tags

    - by Jacques Joubert
    I am looking for help with regular expression $pattern to convert inline image tags like [image:123:title:size] into HTML img tags. here is the code: //[image:ID:caption:size] $content = '[image:38:title:800x900]'; preg_match_all( '/\[image:(\d+)(:?)([^\]]*)\]/i', $content, $images ); if( !empty( $images[0] ) ) { // There are image inline tags in the content foreach( $images[0] as $i => $tag ) { $link_ID = (int)$images[1][$i]; $caption = empty( $images[2][$i] ) ? '#' : $images[3][$i]; $size = empty( $images[4][$i] ) ? '#' : $images[4][$i]; } echo '<br />'; echo 'ID: '.$link_ID.'<br />'; echo 'Tag: '.$caption.'<br />'; echo 'size: '.$size.'<br />'; } which outputs: ID: 12 Tag: caption:size size: # Any help would be great!

    Read the article

  • preg_replace hell

    - by Jason
    I'm trying to use preg_replace to get some data from a remote page, but I'm having a bit of an issue when it comes to sorting out the pattern. function getData($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<span class=\"SectionHeader\"\>title\</span>/<br/>/\<div class=\"header2\"\>(.*)\</div\></span\>/",$str,$title); return $title[1]; } } Here's the HTML as is before I ended up throwing a million slashes at it (looks like I forgot a part or two): <span class="cell CellFullWidth"><span class="SectionHeader">mytitle</span><br/><div class="Center">Event Name</div></span> Where Event Name is the data I want to return in my function. Thanks a lot guys, this is a pain in the ass.

    Read the article

  • php search and replace

    - by Dave
    I am trying to create a database field merge into a document (rtf) using php i.e if I have a document that starts Dear Sir, Customer Name: [customer_name], Date of order: [order_date] After retrieving the appropriate database record I can use a simple search and replace to insert the database field into the right place. So far so good. I would however like to have a little more control over the data before it is replaced. For example I may wish to Title Case it, or convert a delimited string into a list with carriage returns. I would therefore like to be able to add extra formatting commands to the field to be replaced. e.g. Dear Sir, Customer Name: [customer_name, TC], Date of order: [order_date, Y/M/D] There may be more than one formatting command per field. Is there a way that I can now search for these strings? The format of the strings is not set in stone, so if I have to change the format then I can. Any suggestions appreciated.

    Read the article

  • Regex to get rid of everything past the first sentence in a string in php

    - by andufo
    I need to get rid of everything after the first dot (if there is more than 1 sentence), but at the same time, cases like e.g. have to be omited. Some line e.g., when people do something. Extra content. Some line (some parenthesis). Extra content. I need to get rid of the "Extra content.". The returning value should be: Some line e.g., when people do something. Some line (some parenthesis). So far I've come with this regex taken from other threads, but it only finds the dots and split the string into an array. preg_replace('/(?<!\.)\.(?!(\s|$|\,|\w\.))/','',$text); Any ideas? Thanks.

    Read the article

  • how to replace multi string with a array node in js

    - by Rueta
    hi everyone! i here a Work and i don't know how to do it. i have a string here: <div class="demotext"> <p>this is demo string i demo want to demo use</p> </div> i create the array variable for demo: var demoarray = new array('a','b','c'); now i want replace 'demo' in string by array node, follow 'demo' one change to 'a' , 'demo' two change to 'b'....

    Read the article

  • Conditional Regex Replace in C# without MatchEvaluator

    - by Buttink
    So, Im trying to make a program to rename some files. For the most part, I want them to look like this, [Testing]StupidName - 2[720p].mkv But, I would like to be able to change the format, if so desired. If I use MatchEvaluators, you would have to recompile every time. Thats why I don't want to use the MatchEvaluator. The problem I have is that I don't know how, or if its possible, to tell Replace that if a group was found, include this string. The only syntax for this I have ever seen was something like (?<group>:data), but I can't get this to work. Well if anyone has an idea, im all for it.

    Read the article

  • Replace node with innerhtml

    - by Mostafa Mahdieh
    With JavaScript I want to remove a specific DOM node and replace it with the innerHTML. For example I want to change <div> ... <div id="t1"> this is <b> the text </b> I want to remain. </div> ... </div> To <div> ... this is <b> the text </b> I want to remain. ... </div>

    Read the article

  • php preg_replace, regexp

    - by Michael
    I'm trying to extract the postal codes from yell.com using php and preg_replace. I successfully extracted the postal code but only along with the address. Here is an example $URL = "http://www.yell.com/ucs/UcsSearchAction.do?scrambleSeed=17824062&keywords=shop&layout=&companyName=&location=London&searchType=advance&broaderLocation=&clarifyIndex=0&clarifyOptions=CLOTHES+SHOPS|CLOTHES+SHOPS+-+LADIES|&ooa=&M=&ssm=1&lCOption32=RES|CLOTHES+SHOPS+-+LADIES&bandedclarifyResults=1"; //get yell.com page in a string $htmlContent = $baseClass-getContent($URL); //get postal code along with the address $result2 = preg_match_all("/(.*)/", $htmlContent, $matches); print_r($matches); The above code ouputs something like Array ( [0] = Array ( [0] = 7, Royal Parade, Chislehurst, Kent BR7 6NR [1] = 55, Monmouth St, London, WC2H 9DG .... the problem that I have is that I don't know how to extract the the postal code because it doesn't have an exact number of digits (sometimes it has 6 digits and sometimes has only 5 times). Basically I should extract the lasted 2 words from each array . Thank you in advance for any help !

    Read the article

  • Using regular expressions

    - by Tom
    What is wrong with this regexp? I need it to make $name to be letter-number only. Now it doens't seem to work at all. if (!preg_match("/^[A-Za-z0-9]$/",$name)) { $e[]="name must contain only letters or numbers"; }

    Read the article

  • PHP - preg_replace with multiple matches

    - by Neil
    Let's say I have a string like: $text = "<object>item_id1a2b3</object>xxx<object>item_id4c5d6</object>" I want to convert it to: %ITEM:1a2b3xxx%ITEM:4c5d6 Here's what I've got: $text = preg_replace("/<object.*item_id([a-zA-Z0-9]+).*<\/object/","%ITEM:$1",$text); This isn't quite right, as the search is greedy. Thoughts? Thanks!

    Read the article

  • Preg_match class name from PHP file

    - by talentedmrjones
    I have a script that recursively scans a directory pulling out class names from php files, and storing those classes names in an array. This is working nicely even through the rather large Zend Framework library folders. The issue is that classes that extend other classes are not being included in the array. Here is my current preg_match: if (preg_match("/class\s*(\w*)\s*\{/i",strip_comments(file_get_contents($file)),$matches)) $classes[] = $matches[1]; I know that the last \s* is not right; there should be something there that can catch "{" or " extends Some_Other_Class {" .

    Read the article

  • preg_match_all image source

    - by David
    I have the following regex expression which is to extract the source of any img tag in HTML. /(<img).*(src\s*=\s*"([a-zA-Z0-9\.;:\/\?&=\-_|\r|\n]{1,})")/isxmU However, it doesn't appear to be matching the following: <IMG SRC='http://www.mysite.com/pix/lens/mtf/CAEF8512L.gif'> How can I build it to match this as well?

    Read the article

  • PHP & Regular expression: keyword just occurs once

    - by lauthiamkok
    Hi, how can I make sure a certain keyword just occurs once in the input with regular expression? I think there is some mistakes in the expression below as I can repeat the same keywords, if (!preg_match('/\b(.php?){1}\b/', $cfg_path)) { $error = true; echo '<error elementid="cfg_path" message="PATH - make sure you have a \'.php?\' in the path."/>'; } I just want this to be true, form.php?category=something or form.php? but not this, form.php?.php?category=something or form.php?.php? please let me know how to fix it. thanks.

    Read the article

  • SELECT with a Replace()

    - by andyjohnson
    I have a table of names and addresses, which includes a postcode column. I want to strip the spaces from the postcodes and select any that match a particular pattern. I'm trying this (simplified a bit) in T-SQL on SQL Server 2005: SELECT Replace(Postcode, ' ', '') AS P FROM Contacts WHERE P LIKE 'NW101%' But I get the following error; Msg 207, Level 16, State 1, Line 3 Invalid column name 'P'. If I remove the WHERE clause I get a list of postcodes without spaces, which is what I want to search. How should I approach this? What am I doing wrong?

    Read the article

  • preg_match_all problems

    - by NeoNmaN
    i use preg_match_all and need to grab all a href="" tags in my code, but i not relly understand how to its work. i have this reg. exp. ( /(<([\w]+)[^])(.?)(<\/\2)/ ) its take all html codes, i need only all a href tags. i hobe i can get help :)

    Read the article

  • php cURL. preg_match , extract text from xhtml

    - by Michael
    I'm trying to extract the price from the bellow html page/link using php cURL and preg_match . Basically I'm expecting for this code to output 4,550 but for some reasons I get Notice: Undefined offset: 1 in C:\wamp\www\test.php on line 22 I think that the pattern is correct because if I put the html itself in a variable and escape the "" it works ! . Also if I output (echo $result;) it displays the html properly grabbed from foxtons website so I just can't figure it out why the whole thing doesn't work . I need to make this work and also I would appreciate if you would tell me why is that notice generated and why my current script doesn't work. $url = "http://www.foxtons.co.uk/search?bedrooms_from=0&property_id=727717"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_exec($ch); curl_close($ch); $result2 = str_replace('"', '\"', $result); $tagname1= ");<\/script "; $tagname2= "<\/noscript per month<\/a"; $pattern = "/$tagname1(.*?)$tagname2/"; preg_match($pattern, $result, $matches); $prices = $matches[1]; print_r($prices); ?

    Read the article

  • PHP preg_replace - Very quick question

    - by RC
    Masters of regular expressions, please help! See this string: $string = "http://www.url.com/?fieldA=123&fieldB=456&fieldC=789"; Assuming "fieldB" always has a positive non-decimal numerical value (but not necessarily three digits long), what preg_replace command do I need to remove it completely, such that the string will then read: $string = "http://www.url.com/?fieldA=123&fieldC=789"; Thanks!

    Read the article

  • PHP regex to search across multiple lines

    - by Gaz
    I'm using preg_* in PHP to search for the pattern <!-- %{data=THIS GETS MATCHED}% --> and pull out the matched text. The pattern for this is: preg_match('#<!-- %{' . $knownString . '\s*=\s*(.*?)}% -->#', ...) What I would like it to do is search across multiple lines for the string. For example: <!-- %{data= THIS GETS MATCHED AND RETURNED }% --> How can I edit my current pattern to have this search ability?

    Read the article

  • php str_replace pattern

    - by user331071
    Hello , I have a php application that saves the pictures on the server and also stores the picture names in the database . The issue that I have is that the picture names include the path/folder where it was saved from (e.g 1220368812/chpk2198933_large-2.jpg) so I need a str_replace pattern to remove "1220368812/" and have the picture name correct stored in the db . Also I would appreciate if you will send me a good link that explains how exactly the str_replace patterns work or at least how the pattern that you use work .

    Read the article

< Previous Page | 51 52 53 54 55 56 57 58 59 60 61 62  | Next Page >