Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 28/269 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Multiple calls to preg_replace alters result

    - by Hurpe
    I have a bunch of files that were named in a somewhat standard format. The standard form is basically this: [integer]_word1_word2_word3_ ... _wordn where a word could really be anything, but all words are separated by an underscore. There is really only 3 things I want to do to the text: 1.) I want to modify the integer, which is always at the beginning, so that something like "200" would become $ 200.00. 2.) replace any "words" of the form "with", "With", "w/", or "W/" with "with". 3.) Replace all underscores with a space. I wrote three different preg_replace calls to do the trick. They are as follows: 1.) $filename = preg_replace("/(^[0-9]+)/","$ $1.00",$filename) 2.) $filename = preg_replace("/_([wW]|[wW]ith)_/"," with ",$filename) 3.) $filename = preg_replace("/_/"," ",$filename); Each replacement works as expected when run individually, but when all three are run, the 2nd replacement is ignored. Why would something like that occur? Thanks for the help!

    Read the article

  • Preg_match differences?

    - by sky
    Hi, i want to ask, what is the meaning or difference between these two line? if( preg_match_all('/\#([?-?À-ÿ?-??-?a-z0-9\-_]{1,50})/iu', $message, $matches, PREG_PATTERN_ORDER) ) { if( preg_match_all('/\#([?-?a-z0-9\-_\x{4e00}-\x{9fa5}]{1,50})/iu', $message, $matches, PREG_PATTERN_ORDER) ) { and what does the number 3 mean in this line? (Arrow pointing) if( preg_match_all('/\@([a-zA-Z0-9\-_\x{4e00}-\x{9fa5}]{->3,30})/u', $message, $matches, PREG_PATTERN_ORDER) ) { Thanks!

    Read the article

  • How to extract only part of string in PHP?

    - by shin
    I have a following string and I want to extract image123.jpg. ..here_can_be_any_length "and_here_any_length/image123.jpg" and_here_also_any_length image123 can be any length (newimage123456 etc) and with extension of jpg, jpeg, gif or png. I assume I need to use preg_match, but I am not really sure how to code it. Any help will be appreciated. Thanks in advance.

    Read the article

  • php preg_match pattern to extract a specific information, regex

    - by Michael
    I need to extract a specific Id from a html document but the problem is that the id must not "be used". Here is the html content http://pastebin.com/wF2dx8JZ As you may see there are different html blocks . Some of them contain the "Used" word so I need to extract only the first id which is not used. Basically I can write a simple pattern like : $pattern = "/javascript:tw(.*))/"; preg_match_all($pattern, $content, $matches); $id = $matches[1][0]; However in this case I'm also getting the "ids" which are used so I don't know how to exclude them from the equation . Any idea would be highly appreciated.

    Read the article

  • PHP regular expression

    - by Ferol
    such text: $text = ' href="http://yahoo.com" target="_blank"> link text </a> text... text... <br> text...'; // $text = ' text... <a href="http://yahoo.com" target="_blank"> link text </a> text... text... <br> text...'; and such regular expression: preg_match_all('/^(.*)(<.+>)(.*)(<\/.+>)(.*)$/',$text,$matches); what I want, - to check if text matches the regular expression. If yes, then $matches should contain parts of string above, if not (as I guess) it should contain four zero-length arrays. something is wrong, but I can't find, what actually is?

    Read the article

  • PHP regex help with preg_match_all

    - by Steve
    Hi, I am trying to refine a preg_match_all by finding the second occurrence of a period then a space: <?php $str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers."; preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches); $dataarray=$matches[2]; foreach ($dataarray as $value) { echo $value; } ?> But it does not work: the {2} occurrence is incorrect. I have to use preg_match_all because I a scraping dynamic HTML. I want to capture this from the string: East Winds 20 knots. Gusts to 25 knots. Any ideas? Thx

    Read the article

  • PHP RegEx: How to Stripe Whitespace Between Two Strings

    - by roydukkey
    I have been trying to write a regex that will remove whitespace following a semicolon (';') when it is between both an open and close curly brace ('{','}'). I've gotten somewhere but haven't been able to pull it off. Here what I've got: <?php $output = '@import url("/home/style/nav.css"); body{color:#777; background:#222 url("/home/style/nav.css") top center no-repeat; line-height:23px; font-family:Arial,Times,serif; font-size:13px}' $output = preg_replace("#({.*;) \s* (.*[^;]})#x", "$1$2", $output); ?> The the $output should be as follows. Also, notice that the first semicolon in the string still is followed by whitespace, as it should be. <?php $output = '@import url("/home/style/nav.css"); body{color:#777;background:#222 url("/home/style/nav.css") top center no-repeat;line-height:23px;font-family:Arial,Times,serif;font-size:13px}'; ?> Thanks! In advance to anyone willing to give it a shot.

    Read the article

  • How to validate a domain name using Regex & Php?

    - by David
    Hi, I want a solution to validate only domain names not full urls, The following example is what i'm looking for: domain.com -> true domain.net/org/biz... -> true domain.co.uk -> true sub.domain.com -> true domain.com/folder -> false domµ*$ain.com -> false Thank you

    Read the article

  • Detect remote charset in php

    - by yallaa
    Hello, I would like to determine a remote page's encoding through detection of the Content-Type header tag <meta http-equiv="Content-Type" content="text/html; charset=XXXXX" /> if present. I retrieve the remote page and try to do a regex to find the required setting if present. I am still learning hence the problem below... Here is what I have: $EncStart = 'charset='; $EncEnd = '" \/\>'; preg_match( "/$EncStart(.*)$EncEnd/s", $RemoteContent, $RemoteEncoding ); echo = $RemoteEncoding[ 1 ]; The above does indeed echo the name of the encoding but it does not know where to stop so it prints out the rest of the line then most of the rest of the remote page in my test. Example: When testing a remote russian page it printed: windows-1251" / rest of page .... Which means that $EncStart was okay, but the $EncEnd part of the regex failed to stop the matching. This meta header usually ends in 3 different possibility after the name of the encoding. "> | "/> | " /> I do not know weather this is usable to satisfy the end of the maching and if yes how to escape it. I played with different ways of doing it but none worked. Thank you in advance for lending a hand.

    Read the article

  • jQuery .each or search function, how can I make use of those?

    - by Noor
    I have a ul list, with 10 items, and I have a label that displays the selected li text. When I click a button, I need to check the label, versus all the list items to find the matching one, when it finds that I need to assign the corresponding number. I.e. list: Messi Cristiano Zlatan hidden values of list items: www.messi.com www.cronaldo.com www.ibra.com label: Zlatan script (thought)procces: get label text, search list for matching string, get the value of that string. (and if someone could point me in a direction to learn these basic(?) stuff. tried to be as specific as possible, thanks guys!

    Read the article

  • preg_match , regexp , php , extract text from html

    - by Michael
    I'm trying to extract "Florida (FL)" from http://www.auctionarms.com/search/displayitem.cfm?itemnum=9736364&oh=216543. My code is //get location $pattern = "/(State)<\/i\:<\/td(.*)<\/td/"; preg_match_all($pattern, $htmlContent, $matches); print_r($matches); any idea why is not working ?

    Read the article

  • preg_match Vs preg_match_all browser error not php?

    - by Phil Jackson
    Hi all i have the following: $str = base64_encode(preg_replace("#\s|\r|\t|\n#", " ", file_get_contents("../www.cms.actwebdesigns.co.uk2/logged.php"))); if(preg_replace("#(PD9waHAg)((?!(Pz4g)).)*#is", $str, )) { #print_r($matches); echo "<xmp>".base64_decode($matches[0]."Pz4g")."</xmp>"; } now this works but i want to be able to use it for all occurrences on page. (finds php segments in page) So i used preg_match_all but returns a browser error (page has been moved or no longer exists) Anyone know why?

    Read the article

  • XPath: How to check multiple attributes across similar nodes

    - by Justin
    Hi, If I have some xml like: <root> <customers> <customer firstname="Joe" lastname="Bloggs" description="Member of the Bloggs family"/> <customer firstname="Joe" lastname="Soap" description="Member of the Soap family"/> <customer firstname="Fred" lastname="Bloggs" description="Member of the Bloggs family"/> <customer firstname="Jane" lastname="Bloggs" description="Is a member of the Bloggs family"/> </customers> </root> How do I get, in pure XPath - not XSLT - an xpath expression that detects rows where lastname is the same, but has a different description? So it would pull the last node above? Thanks a mill if you can help, been scratching at it for ages, and I can't find it by searching (apologies if it is) Cheers, J

    Read the article

  • .each or search function, how can I make use of those?

    - by Noor
    I have a ul list, with 10 items, and I have a label that displays the selected li text. When I click a button, I need to check the label, versus all the list items to find the matching one, when it finds that I need to assign the corresponding number. I.e. list: Messi Cristiano Zlatan hidden values of list items: www.messi.com www.cronaldo.com www.ibra.com label: Zlatan script (thought)procces: get label text, search list for matching string, get the value of that string. (and if someone could point me in a direction to learn these basic(?) stuff. tried to be as specific as possible, thanks guys! edit: really sorry for not being clear. the li's are all getting a class dynamically (.listitem). the links can be stored in an array or in a hidden field (or other ul thats hidden) it doesn't really matter where the links are.. $('.listitem').click(function() { $("#elname").text($(this).text()); $("#such").attr("href", $(this).attr('value')); }); I was trying that with the li's having values but I realized that li's can't have values.. thanks again!

    Read the article

  • Simplest way to convert all html links in a string using PHP

    - by Gaz
    I am trying to convert a block of text that contains html text - i'd like to find all http links and convert them for link tracking purposes. So eg anything like this in a string would be converted to the latter <a href="http://www.google.com">Some Link</a> <a href="http://www.mysite.com/tracking.php?url=www.google.com">Some Link</a> Can anyone how to do this taking into account the original string will consists of all sorts of html, images etc..

    Read the article

  • How can I partial compare two strings in C?

    - by Nazgulled
    Hi, Let's say I have the following content: Lorem Ipsum is simply dummy text of the printing and typesetting industry. How do I search for dummy or dummy text in that string using C? Is there any easy way to do it or only with strong string manipulation? All I need is to search for it and return a boolean with the result.

    Read the article

  • Minify CSS using preg_replace

    - by x3ro
    Hey folks, I'm trying to minify multiple CSS files using preg_replace. Actually, I'm only trying to remove any linebreaks/tabs and comments from the file. the following works for me: $regex = array('{\t|\r|\n}', '{(/\*(.*?)\*/)}'); echo preg_replace($regex, '', file_get_contents($file)); But I'd like to do it in a single multiline regex, like this: $regex = <<<EOF {( \t | \r | \n | /\*(.*?)\*/ )}x EOF; echo preg_replace($regex, '', file_get_contents($file)); However, this does not do anything at all. Is there any way to do this? Regards, x3ro Edit: Ok, so I'll take a look at existing minifiers, but it still leaves me with the question how I would do a multiline regex like this, because with the x-modifier multiline regexs should work fine even in php, shouldn't they?

    Read the article

  • preg_replace function to append a string to all the hyperlinks of a page

    - by KoolKabin
    hi guys, i want to append my own value to all hyperlinks in a page... e.g if there are links: <a href="abc.htm?val=1">abc 1</a> <br/> <a href="abc.htm?val=2">abc 1</a> <br/> <a href="abc.htm?val=3">abc 1</a> <br/> <a href="abc.htm?val=4">abc 1</a> <br/> I want to add next var like "type=int" to all hyperlinks output should be: <a href="abc.htm?val=1&type=int">abc 1</a> <br/> <a href="abc.htm?val=2&type=int">abc 1</a> <br/> <a href="abc.htm?val=3&type=int">abc 1</a> <br/> <a href="abc.htm?val=4&type=int">abc 1</a> <br/> I hope it can be done quite easily with preg_replace function

    Read the article

  • Replace whitespaces using PHP preg_replace function ignoring quoted strings

    - by Saiful
    Look at the following string: SELECT column1 , column2, column3 FROM table1 WHERE column1 = 'text, "FROM" \'from\\\' x' AND column2 = "sample text 'where' \"where\\\" " AND ( column3 = 5 ) I need to escape unnecessary white space characters from the string like: removing white space from beginning and ending position of , ( ) etc removing newline (\r\n) and tabs (\t) But one thing. The remove process could not remove white spaces from the quoted string like: 'text, "FROM" \'from\\' x' "sample text 'where' \"where\\" " etc. i need to use the PHP function: preg_replace($pattern, $replacement, $string); So what will be the value of $pattern and $replacement where the value of $string is the given SQL.

    Read the article

  • 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

  • preg_replace to remove some unwanted divs

    - by Jason
    Hi All, In the following code, I need to remove . They will always be at the start and finish of my string, for example: <div class="grid_8"><img src="http://rps.sanscode.com/site/assets/media/images/rps_mini_logo.png" border="0" alt="Rapid Print Solutions" style="margin-bottom: 30px;" /> <h1></h1> </div> What is a suitable regex for preg_replace to remove it? 8 can be any number between 1 and 16. Thanks Jason

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >