Search Results

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

Page 31/269 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • preg_match_all confusing failing

    - by James
    $string = (string) file_get_contents($_FILES['file']['tmp_name']); echo $string; preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches); print_r($matches); I am parsing text/csv files and grabbing email addresses from uploaded files. When parsing a Google Contact file I exported it weirdly fails. But when I simply copy the string that is echo'd and paste that instead of the file_get_contents result, it parses and works. Any idea why it is refusing to take the file_get_contents string, but if I paste in the raw data myself, it works?

    Read the article

  • Split a string by comma, quote and full-stop.. with a few exceptions

    - by dunc
    I've got a lot of text, similar to the following paragraph, which I'd like to split into words without punctuation (', ", ,, ., newline etc).. with a few exceptions. Initially considered endemic to the Chalakudy River system in Kerala state, southern India, but now recognised to have a wider distribution in surrounding drainages including the Periyar, Manimala, and Pamba river though the Manimala data may be questionable given it seems to be the type locality of P. denisonii. In the Achankovil River basin it occurs sympatrically, and sometimes syntopically, with P. denisonii. Wild stocks may have dwindled by as much as 50% in the last 15 years or so with collection for the aquarium trade largely held responsible although habitats are also being degraded by pollution from agricultural and domestic sources, plus destructive fishing methods involving explosives or organic toxins. The text refers to P. denisonii which is a species of fish. It's an abbreviation of Genus species. I would like this reference to be one word. So, for instance, this is the kind of array I'd like to see: Array ( ... [44] given [45] it [46] seems [47] to [48] be [49] the [50] type [51] locality [52] of [53] P. denisonii [54] In [55] the ... ) The only things that distinguish these species references such as P. denisonii from a new sentence like end. New are: The P (for Puntius, as in the P. in the aforementioned example) is only ever one letter, always a capital the d (as in . denisonii) is always either a lower case letter or an apostrophe (') What regexp can I use with preg_split to give me such an array? I've tried a simple explode( " ", $array ) but it doesn't do the job at all. Thanks in advance,

    Read the article

  • what is the regular expression for this

    - by bn
    I want to parse this (adv) much (thanks) I want to eliminate the words and the bracket (adv) but not (thanks) the condition is: inside bracket, and word length inside bracket is 1-5 characters I am using preg_match in PHP Thank You

    Read the article

  • preg_match_all to get all occurrences of a string

    - by i5z
    I am trying to find offset of all occurrences with preg_match_all e.g. $haystack = 'aaaab'; $needle = 'aa'; preg_match_all('/' . $needle . '/', $haystack, $matches); $matches is Array ( [0] => Array ( [0] => Array ( [0] => aa [1] => 0 ) [1] => Array ( [0] => aa [1] => 2 ) ) ) It returns offset of first and second group of aa ("aa" "aa" "b") from the haystack, while I am expecting it to return "aa" starting at index 1 as well. Array ( [0] => Array ( [0] => Array ( [0] => aa [1] => 0 ) [1] => Array ( [0] => aa [1] => 1 ) [2] => Array ( [0] => aa [1] => 2 ) ) ) Is there a way I can fix the regex or use some other function (which accepts regex) to get this done? PS: I know strpos which can do this, but I have few more things to search for hence will go with preg_match_all.

    Read the article

  • How do I extract info from a block of URLs in php?

    - by Jack
    I have a list of urls, which can come in any format. One per line, separated by commas, have random text in between them, etc. the URLs are all from 2 different sites, and have a similar structure For this example, lets say it looks like this Random Text - http://www.domain2.com/variable-value Random Text 2 - http://www.domain1.com/variable-value, http://www.domain1.com/variable-value, http://www.domain1.com/variable-value http://www.domain1.com/variable-value http://www.domain2.com/variable-value http://www.domain1.com/variable-value http://www.domain2.com/variable-value http://www.domain1.com/variable-value I need to extract 2 pieces of information. Check to see if its domain1 or domain2 and the value that follows "variable-" So it should create a multi-dimensional array, which would have 2 items: domain + value. Whats the best way of doing that?

    Read the article

  • How do I extract specific data with preg_match?

    - by paulswansea
    I'm looking to extract values from a whole load of html (i've just trimmed down to the relevant data), there are multiple 'select' elements, and only want to extract those who's 'name' element matches the name 'aMembers'. So the resulting values I would like to retrieve are 5,10,25 and 30 (see below) how can I achieve this with preg_match? <DIV id="searchM" class="search"><select name="aMembers" id="aMembers" tabIndex="2"> <option selected="selected" value="">Data 3</option> <option value="5">A name</option> <option value="10">Another name</option> </select> </DIV> <DIV id="searchM" class="search"><select name="bMembers" id="bMembers" tabIndex="2"> <option selected="selected" value="">Data 2</option> <option value="15">A name</option> <option value="20">Another name</option> </select> </DIV> <DIV id="searchM" class="search"><select name="aMembers" id="Members" tabIndex="2"> <option selected="selected" value="">Data 1</option> <option value="25">A name</option> <option value="30">Another name</option> </select> </DIV>

    Read the article

  • What is the best Networking implementation for my application?

    - by CaptainPhil
    I am in the planning phases of a project for myself, it is to be a single and multi-player card game. I would like to track statistics for each person such as world rankings etc... My problem is I do not know the best approach for the client - server architecture and programming. My original goal was to program everything in C# as I want to get proficient in that language. My original idea was to have a back-end database and a back end server run on some sort of hosting on the internet, however that seems costly for such a small project that may or may not make any money. I have tried looking into cloud services however I am unfamiliar with the technology, and I am not sure I can make them suit my needs, especially since most like Google's cloud wants you to use their coding architecture from what I understand. Finally my last problem is that I would like an architecture that can be used for different languages so that I can port it from PC to IPhone, Xbox etc... So does anyone have any advice on the best architecture and language to do this in? Am I worrying about architecture and back-end costs to much and should just concentrate on getting the game running any which way?

    Read the article

  • Get all text between tags with preg_match_all() or better function?

    - by kylex
    2010-June-11 <remove>2010-June-2</remove> <remove>2010-June-3</remove> 2010-June-15 2010-June-16 2010-June-17 2010-June-3 2010-June-2 2010-June-1 I'm trying to find all instances that are between the <remove> tags This is what I have: $pattern = "/<remove>(.*?)<\/remove>/"; preg_match_all($pattern, $_POST['exclude'], $matches); foreach($matches as $deselect){ foreach ($deselect as $display){ echo $display."<br />"; } } This is what it returns: 2010-June-2 2010-June-3 2010-June-2 2010-June-3 Why is it doubling up, and how do I prevent that?

    Read the article

  • Replace non-html links with <A> tags

    - by tombazza
    I have a block of code that will take a block of text like the following: Sample text sample text http://www.google.com sample text Using the preg_replace_callback method and the following regular expression: preg_replace_callback('/http:\/\/([,\%\w.\-_\/\?\=\+\&\~\#\$]+)/', create_function( '$matches', '$url = $matches[1]; $anchorText = ( strlen($url) > 35 ? substr($url, 0, 35).\'...\' : $url); return \'<a href="http://\'. $url .\'">\'. $anchorText .\'</a>\';'), $str); Will convert the sample text to look like: Sample text sample text < a href="http://www.google.com"http://www.google.com< /a sample text My problem now is that we have introduced a rich text editor that can create links before being sent to the script. I need to update this piece of code so that it will ignore any URLs that are already inside an tag.

    Read the article

  • preg_replace replacing with array

    - by Scott
    What I want to do is replace the "[replace]" in input string with the corresponding vaule in the replace array. The total number of values will change but there will always be the same number in the replace array as in input string. I have tried doing this with preg_replace and preg_replace_callback but I can't get the pattern right for [replace], I also tried using vsprintf but the % in <table width="100%"> was messing it up. All help is greatly appreciated! Replace Array: $array = array('value 1','value 2','value 3'); Input String $string = ' <table width="100%"> <tr> <td>Name:</td> <td>[replace]</td> </tr> <tr> <td>Date:</td> <td>[replace]</td> </tr> <tr> <td>Info:</td> <td>[replace]</td> </tr> </table> '; Desired Result <table width="100%"> <tr> <td>Name:</td> <td>value 1</td> </tr> <tr> <td>Date:</td> <td>value 2</td> </tr> <tr> <td>Info:</td> <td>value 3</td> </tr> </table>

    Read the article

  • JAVA : How to get the positions of all matches in a String?

    - by user692704
    I have a text document and a query (the query could be more than one word). I want to find the position of all occurrences of the query in the document. I thought of the documentText.indexOf(query) and using regular expression but I could not make it work. I end up with the following method: First, I have create a dataType called QueryOccurrence public class QueryOccurrence implements Serializable{ public QueryOccurrence(){} private int start; private int end; public QueryOccurrence(int nameStart,int nameEnd,String nameText){ start=nameStart; end=nameEnd; } public int getStart(){ return start; } public int getEnd(){ return end; } public void SetStart(int i){ start=i; } public void SetEnd(int i){ end=i; } } Then, I have used this datatype in the following method: public static List<QueryOccurrence>FindQueryPositions(String documentText, String query){ // Normalize do the following: lower case, trim, and remove punctuation String normalizedQuery = Normalize.Normalize(query); String normalizedDocument = Normalize.Normalize(documentText); String[] documentWords = normalizedDocument.split(" ");; String[] queryArray = normalizedQuery.split(" "); List<QueryOccurrence> foundQueries = new ArrayList(); QueryOccurrence foundQuery = new QueryOccurrence(); int index = 0; for (String word : documentWords) { if (word.equals(queryArray[0])){ foundQuery.SetStart(index); } if (word.equals(queryArray[queryArray.length-1])){ foundQuery.SetEnd(index); if((foundQuery.End()-foundQuery.Start())+1==queryArray.length){ //add the found query to the list foundQueries.add(foundQuery); //flush the foundQuery variable to use it again foundQuery= new QueryOccurrence(); } } index++; } return foundQueries; } This method return a list of all occurrence of the query in the document each one with its position. Could you suggest any easer and faster way to accomplish this task. Thanks

    Read the article

  • Matching two sections same number of times

    - by Leszczu
    Hello, i need a HTML to parse: <span>some text<span><span><span>text</span></span></span></span> I need to remove unnecessary <span> occurrences, so that output is: <span>some text<span>text</span></span> I wrote a regex, which does this once: /<SPAN>[^<]*<\/SPAN>/i How to make this work same number of times on both <span> and </span>?

    Read the article

  • Wordpress curl save Images

    - by Jeton Ramadani
    I am working on saving images from external sites into a folder in my wordpress theme. And I was wondering if its Ok to call curl twice or can it be done with one time. Example: $data = get_url('http://www.veoh.com/watch/v19935546Y8hZPgbZ'); // getting the url first curl instance preg_match('/fullHighResImagePath="(.*?)"/', $data, $thumbnail); // find the image from content savePhoto($thumbnail, $post->ID); //2nd instance of curl to save the image function get_url($url) { $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2)"; $ytc = curl_init(); // initialize curl handle curl_setopt($ytc, CURLOPT_URL, $url); // set url to post to curl_setopt($ytc, CURLOPT_FAILONERROR, 1); // Fail on errors curl_setopt($ytc, CURLOPT_FOLLOWLOCATION, 1); // allow redirects curl_setopt($ytc, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ytc, CURLOPT_PORT, 80); //Set the port number curl_setopt($ytc, CURLOPT_TIMEOUT, 15); // times out after 15s curl_setopt($ytc, CURLOPT_HEADER, 1); // include HTTP headers curl_setopt($ytc, CURLOPT_USERAGENT, $user_agent); $source = curl_exec($ytc); curl_close($ytc); $data = trim( $source ); return $data; } function savePhoto($remoteImage, $isbn) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $remoteImage); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0); $fileContents = curl_exec($ch); curl_close($ch); if (DIRECTORY_SEPARATOR=='/'){ $absolute_path = dirname(__FILE__).'/'; } else { $absolute_path = str_replace('\\', '/', dirname(__FILE__)).'/'; } $newImg = imagecreatefromstring($fileContents); return imagejpeg($newImg, $absolute_path ."video_images/{$isbn}.jpg",100); }

    Read the article

  • Syncing Music Everywhere with Google Music and iTunes Match - Will This Work?

    - by dragonmantank
    I have the following devices: Personal Laptop running Windows 7/Ubuntu 11.10 (mostly use Ubuntu) Media Server running Windows 7 with PS3 Media Server and iTunes Work Laptop running OSX Snow Leopard iPad iPhone 4S The iPhone just replaced my Droid 2 Global. What I had been doing was using Google Music to watch the folders iTunes was storing music in and moving any new files up to Google Music. The Droid would pull music down from the cloud via streaming or me telling it to make it available offline, I had folders set up with PS3 Media Server to stream them to TV's via DLNA, and used RDP to play music through my speakers in the office. So far it's worked well. Since I've replaced the Droid 2 though with an iPhone, I've lost the syncing ability with Google Music and have to do it via iTunes (I knew this would happen, no big suprise). I got to thinking though - Apple does offer iTunes Match, which allows your devices to stream/download the music from 'the cloud,' much like Google Music. I could then listen to whatever I Wanted (for the most part) on my phone, iPad, and laptops by syncing via iTunes Match. I don't want to loose my MP3s though, and since I've never used iTunes Match, I wonder if the following is a viable solution: Sign up for iTunes Match on my media server Let it scan my library and make available my songs in AAC in the cloud Not delete the media server MP3s Set up other devices to sync to iTunes Match Continue to get MP3s via Amazon or other services and add to iTunes Let the MP3s sync to Google Music, and let the MP3's add to the AAC versions on my devices I think the main kicker is I don't want to lose the MP3 versions of my songs as those will work just fine on all my devices and I generally rip at 320kbps. I don't mind spending $25/year if it means that I can easily shift the music from device to device without much thinking, but I'm not going to pay $25/year to end up converting my library over to AAC just to save myself the hassle of manually syncing my iPad and iPhone.

    Read the article

  • Explain a block of crazy JS code inside Sizzle(the CSS selector engine)

    - by Andy Li
    So, here is the function for pre-filtering "CHILD": function(match){ if ( match[1] === "nth" ) { // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); // calculate the numbers (first)n+(last) including if they are negative match[2] = (test[1] + (test[2] || 1)) - 0; match[3] = test[3] - 0; } // TODO: Move to normal caching system match[0] = done++; return match; } The code is extracted from line 442-458 of sizzle.js. So, why is the line var test = ..., have the exec inputing a boolean? Or is that really a string? Can someone explain it by splitting it into a few more lines of code?

    Read the article

  • RegexClean Transformation

    Use the power of regular expressions to cleanse your data right there inside the Data Flow. This transformation includes a full user interface for simple configuration, as well as advanced features such as error output configuration. Two regular expressions are used, a match expression and a replace expression. The transformation is designed around the named capture groups or match groups, and even supports multiple expressions. This allows for rich and complex expressions to be built, all through an easy to reuse transformation where a bespoke Script Component was previously the only alternative. Some simple properties are available for each column selected – Behaviour The two behaviour modes offer similar functionality but with a difference. Replace, replaces tokens with the input, and Emit overwrites the whole string. Cascade Cascade allows you to define multiple expressions, each on a new line. The match expression will be processed into one operation per line, which are then processed in order at run-time. Multiple replace expressions can also be specified, again each on a new line. If there is no corresponding replace expression for a match expression line, then the last replace expression will be used instead. It is common to have multiple match expressions, but only a single replace expression. Match Expression The expression used to define the named capture groups. This is where you can analyse the data, and tag or name elements within it as found by the match expression. Replace Expression The replace determines the final output. It will reference the named groups from the match expression and assembles them into the final output. If you want to use regular expressions to validate data then try the Regular Expression Transformation. Quick Start Guide Select a column. A new output column is created for each selected column; there is no option for in-place replacement of column values. One input column can be used to populate multiple output columns, just select the column again in the lower grid, using the Input Columns drop-down selector. Amend the output column name and size as required. They default to the same as the input column selected. Amend the behaviour as required, the default is Replace. Amend the cascade option as required, the default is true. Finally enter your match and replace regular expressions Quick Sample #1 Parse an email address and extract the user and domain portions. Format as a web address passing the user portion as a URL parameter. This uses two match groups, user and host, which correspond to the text before the @ and after it respectively. Behaviour is Emit, and cascade of false, we only have a single match expression. Match Expression ^(?<user>[^@]+)@(?<host>.+)$ Replace Expression - http://www.${host}?user=${user} Results Sample Input Sample Output [email protected] http://www.adventure-works.com?user=zheng0 The component is provided as an MSI file, however to complete the installation, you will have to add the transformation to the Visual Studio toolbox manually. Right-click the toolbox, and select Choose Items.... Select the SSIS Data Flow Items tab, and then check the RegexClean Transformation from the list. Downloads The RegexClean Transformation is available for both SQL Server 2005 and SQL Server 2008. Please choose the version to match your SQL Server version, or you can install both versions and use them side by side if you have both SQL Server 2005 and SQL Server 2008 installed. RegexClean Transformation for SQL Server 2005 RegexClean Transformation for SQL Server 2008 Version History SQL Server 2005 Version 1.0.0.105 - Public Release (28 Jan 2008) SQL Server 2005 Version 1.0.0.105 - Public Release (28 Jan 2008) Screenshot

    Read the article

  • Google Analytics API data for goals (funnels) doesn't match - how do they reconcile?

    - by bkgraham
    I have a Google Analytics account with a well-functioning funnel made up of 4 goals. I can query the API and get the data out, but it does not match the funnel report in Analytics. Without getting into specific values, I can give you an example with faked data. Here's how the funnel might look: Shopping Cart 100 > 100 > 20 80 (80%) Address Page 5 > 85 > 25 60 (71%) Payment Page 2 > 62 > 10 52 (84%) Checkout 1 > 53 (49.07% funnel conversion rate) Okay, so you would expect the API to output data something like this: goal1Starts goal1Completions goal1Abandons 100 80 20 goal2Starts goal2Completions goal2Abandons 85 60 25 goal3Starts goal3Completions goal3Abandons 62 52 10 goal4Starts goal4Completions goal4Abandons 53 53 0 Instead, it's different. Firstly, the abandons are associated with the following goal (so goal1 always has 0 abandons and goal4 always has 0 abandons. Okay, I can work with that. What's confusing is that the numbers are always a little different. The goal1Completions always match the report, as do the goal4Completions, but everything else is off by a small amount. Sometimes it's only 2 visits, other times it's off by 50. For the report above here's the kind of results I would tend to get: goal1Starts goal1Completions goal1Abandons 100 100 0 goal2Starts goal2Completions goal2Abandons 105 84 21 goal3Starts goal3Completions goal3Abandons 90 65 25 goal4Starts goal4Completions goal4Abandons 58 53 5 Here's what I know: Goal(n)Completions + Goal(n)Abandons = Goal(n)Starts Goal(n)Starts = Goal(n-1)Completions Goal(n)Starts - Goal(n-1)Completions != reported number entering at that level That third one is particularly disappointing. So, here's my question: What data do I need to pull from the API in order to recreate the counts in the Funnel report in Google Analytics? I don't need the pages exited to entering from - just the counts at every level.

    Read the article

  • Watch IPL League 2010 Online On YouTube

    - by Suganya
    Having said that IPL League match for the year 2010 starts tomorrow, Many of us would be interested in watching the broadcast live online. The first match between Deccan chargers and Kolkata Knight Riders starts tomorrow at 20.00 IST. IPL T20 lasts for 45 days starting from March 12th 2010 till April 25th 2010. The entire league takes place in India. The opening ceremony takes place on 12th continued by the official game between Deccan Chargers and Kolkata Knight Riders Most of us would not be able to watch the match on Television. So this year IPL joins hand with Google to make it available live on NET. How to Watch IPL Match Live Online Google and IPL has joined their hands to make the match available online for all the viewers around the world. To watch the IPL Match live online log on here How to Watch IPL Match Live On Mobile IPL and GCV(Global Cricket Ventures) are tied to July Systems. You can watch IPL matches live on mobile by accessing the link directly using a GPRS enabled mobile or viewers can simply call from their mobile phone to MiX (Mobile Internet Experience) using the Toll Free number 08 123 123 123. Once you call this Toll Free number a link will be sent to your mobile. You can access that link to view the live cricket on your mobile. Watch IPL League Cricket Match Live Online Watch IPL League Cricket Match Live On Mobile Join us on Facebook to read all our stories right inside your Facebook news feed.

    Read the article

  • Do I need to match hardware on a Mac to my PC to get the same user experience?

    - by Darth
    I've been playing around with the thought of moving from a PC to a Mac. if you don't want to read this, skip to the "upgrade options" My current setup Most of my time I spent moving back and forth between Linux and Windows. During the last upgrade to Vista, I got myself pc with Core 2 Quad, 8GB of RAM and GeForce 9800GTX+. Currently I'm running dual boot between Ubuntu 10.04 and Windows Vista x64. Most of my work, around 80%, I can do on Ubuntu, which is mostly Ruby/Java programming. If that was all I needed, Ubuntu would be really great. However, I also do quite a lot of Photography and Design, which forces me to use Adobe software (not only Photoshop). I also work with Wacom Intuos4 tablet, which doesn't really have great support on Linux machines. I've tried virtualization both ways (Linux in Win and Win in Linux), but neither was anywhere near satisfying. These are those of many many reasons I want to move to OS X. Upgrade options This is how I see my upgrade options: Mac Mini - cheapest solution, but worst performance iMac - more expensive, better performing with second LCD for free Mac Pro - could match my current PC performance, currently outside of the price range When I compare the Mac hardware vs my current PC, it will be always worse, unless I decide to pump in a lot of money. The question that comes to my head, do I need to match my current PC hardware to get the same user experience with a Mac? If I look at it from the Vista point of view, 2GB RAM is as low as it gets, 4GB is usable ... and the 8GB runs very smoothly. PC HW != Mac HW? If I bought the Mac Mini for roughly the same price I paid for my PC (Core 2 Quad with 8GB RAM), I'd get Core 2 Duo with 4GB RAM. But I don't want to run Vista on it, so I can't compare the hardware directly. Say that I want to do the same things on the Mac Mini as I do on my PC, eg. open up 50 tabs in Google Chrome and start working with a large PSD in Photoshop (couple hundred MB), would running on Mac OS X compensate for the lower hardware performance? My point is, that if I'm about to upgrade, I wouldn't like to upgrade to hardware that runs a lot slower. Good analogy for this is Vista vs Ubuntu, where you can run Ubuntu smoothly on a low end laptop, but in Vista, you'd be happy to open a browser. Does the same principle apply to OS X?

    Read the article

  • how to watch??? England vs Belgium live stream Soccer friendly match ESPN

    - by Dada Fafa
    Do you want to watch:England vs Belgium live streaming online on pc?Searching for a good way to watch England vs Belgium live streaming online today? You've come to the right place!We'll show you how to watch England vs BelgiumNBA games live stream online in perfect high definition quality using any PC or Mac computer! It's possible! Now you can watch every minute of England vs Belgiumonline live,and in true HD quality no matter where you are! WANNA WATCH England vs Belgium LIVE STREAM MATCH

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >