Search Results

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

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

  • Regular Expression issue

    - by Christian Sciberras
    I have the following URL structure which I need to match to and get the particular id from: /group/subgroup/id-name In short, I need to translate a URL like the following: /Blue Products/Dark Blue/5-Blue_Jelly To: /?pagename=Blue Products&model=5 IMPORTANT: I don't need to match group, I already have group. Example code: <?php foreach($cats as $cat) $cmd->rewrite('/\/'.$cat.'\/unused\/(ID)-unused\//','/?pagename='.$cat.'&model=%ID%'); ?> Edit: This is the completed code: if($groups->count()){ $names=array(); foreach($groups->rows as $row) $names[]=preg_quote($row->group); $names=implode('|',$names); $regex='('.$names.')/([^/]+)/([0-9]{1,})-([^/]+)/?$'; CmsHost::cms()->rewrite_url($regex,'index.php?pagename=Products',true); }

    Read the article

  • Replace existing XML file within iPhone app

    - by Chonch
    Hey, I have an .xml file that is going to be shipped within my app. This file contains values that are read from it and saved as an array when the app launches. Each time the app is run, I want to check with the server if there is an internet connection. If so, I want to get the newest version of the .xml file from the server and replace the one that I currently have saved in my app (this way, the next time the user logs in and doesn't have internet access, he/she will be able to use the old (yet most up to date) data). What is the best way to do this? Thanks,

    Read the article

  • Regular Expression Sanitize (PHP)

    - by atif089
    Hello, I would like to sanitize a string in to a URL so this is what I basically need. Everything must be removed except alphanumeric characters and spaces and dashed. Spaces should be converter into dashes. Eg. This, is the URL! must return this-is-the-url Thanks

    Read the article

  • DB2 Select - Replace STATES with two character code

    - by user2528724
    I have a Users Table where it stores city, state and country along with other Users attributes. The states are stored as California, Alabama and so forth. Now I want to retrieve the user information for certain records but the state should get translated to two digit code. Say 'California' should be 'CA'. How should I go about doing this. I was thinking to create a mapping table for state names with there abbreviation and then use some sort of replace function to do it. Any ideas ?

    Read the article

  • Searching within an array of strings...

    - by SoLoGHoST
    Ok, I'm feeling retarded here, I have a string like so: $string = 'function module_testing{'; or it could be like this: $string = 'function module_testing'; And than I have an array of strings like so: $string_array = array('module_testing', 'another_function', 'and_another_function'); Now, is there some sort of preg_match that I can do to test if any of the $string_array values are found within the $string string at any given position? So in this situation, there would be a match. Or is there a better way to do this? I can't use in_array since it's not an exact match, and I'd rather not do a foreach loop on it if I can help it, since it's already in a while loop. Thanks :)

    Read the article

  • Break a string into parts, returning all characters

    - by Benjamin
    I want to break a string according to the following rules: all consecutive alpha-numeric chars, plus the dot (.) must be treated as one part all other consecutive chars must be treated as one part consecutive combinations of 1 and 2 must be treated as different parts no whitespace must be returned For example this string: Method(hierarchy.of.properties) = ? Should return this array: Array ( [0] => Method [1] => ( [2] => hierarchy.of.properties [3] => ) [4] => = [5] => ? ) I was unsuccessful with preg_split(), as AFAIK it cannot treat the pattern as an element to be returned. Any idea for a simple way to do this?

    Read the article

  • JavaScript Regular expressions, match and replace link

    - by Thoman
    Hello please help me <html> <body> http://domainname.com/abc/xyz.zip http://domainname2.com/abc/xyz.zip </body> </html> I want replace with link and out put like <html> <body> <a href="http://domainname.com/abc/xyz.zip">http://domainname.com/abc/xyz.zip</a> <a href="http://domainname2.com/abc/xyz.zip">http://domainname2.com/abc/xyz.zip</a> </body> </html> Great Thank

    Read the article

  • PHP preg_match: a pattern which satisfies all MySQL field names (including 'table.field' formations)

    - by gsquare567
    i need a pattern which satisfies mysql field names, but also with the option of having a table name before it examples: mytable.myfield myfield my4732894__7289FiEld here's what i tried: $pattern = "/^[a-zA-Z0-9_]*?[\.[a-zA-Z0-9_]]?$/"; this worked for what i needed before, which was just the field name: $pattern = "/^[a-zA-Z0-9_]*$/"; any ideas why my addition isnt working? maybe i'm making up regex, so i'll explain what i added... the first '?' is to say that it isn't greedy, ie. it will stop if the next part, namely "[.[a-zA-Z0-9_]]?" is satisfied. now, that second part is just the same as the first except it is optional (hence the '?' at the end) and it starts with a period (hence the '[.' and ']' wrapping my old clause. and obviously, the "^" and "$" rep the beginning and end of the string so... any ideas? (also, i'm a tad confused as to why i need to put in those "/"s in the begining/end anyways, so if you could tell me why it's required, that'd be awesome) thanks a lot! (and thanks for reading this all if you actually did... it's quite a ramble)

    Read the article

  • Download and replace Android resource files

    - by Casebash
    My application will have some customisation for each company that uses it. Up until now, I have been loading images and strings from resource files. The idea is that the default resources will be distributed with the application and company specific resources will be loaded from our server after they click on a link from an email to launch the initialisation intent. Does anyone know how to replace resource files? I would really like to keep using resource files to avoid rewriting a lot of code/XML. I would distribute the application from our own server, rather than through the app store, so that we could have one version per company, but unfortunately this will give quite nasty security warnings that would concern our customers.

    Read the article

  • How do I process the largest match first in PHP?

    - by animuson
    Ok, so I tried searching around first but I didn't exactly know how to word this question or a search phrase. Let me explain. I have data that looks like this: <!-- data:start --> <!-- 0:start --> <!-- 0:start -->0,9<!-- 0:stop --> <!-- 1:start -->0,0<!-- 1:stop --> <!-- 2:start -->9,0<!-- 2:stop --> <!-- 3:start -->9,9<!-- 3:stop --> <!-- 4:start -->0,9<!-- 4:stop --> <!-- 0:stop --> <!-- 1:start --> <!-- 0:start -->1,5<!-- 0:stop --> <!-- 1:start -->1,6<!-- 1:stop --> <!-- 2:start -->3,6<!-- 2:stop --> <!-- 3:start -->3,8<!-- 3:stop --> <!-- 4:start -->4,8<!-- 4:stop --> <!-- 1:stop --> <!-- 2:start --> <!-- 0:start -->0,7<!-- 0:stop --> <!-- 1:start -->1,7<!-- 1:stop --> <!-- 2:stop --> <!-- data:stop --> So it's basically a bunch of points. Here is the code I'm currently using to try and parse it so that it would create an array like so: Array ( 0 => Array ( 0 => "0,9", 1 => "0,0", 2 => "9,0", 3 => "9,9", 4 => "0,9" ), 1 => Array ( 0 => "1,5", 1 => "1,6", 2 => "3,6", 3 => "3,8", 4 => "4,8" ), 2 => Array ( 0 => "0,7", 1 => "1,7" ) ) However, it is returning an array that looks like this: Array ( 0 => "0,9", 1 => "0,0", 2 => "9,0" ) Viewing the larger array that I have on my screen, you see that it's setting the first instance of that variable when matching. So how do I get it to find the widest match first and then process the insides. Here is the function I am currently using: function explosion($text) { $number = preg_match_all("/(<!-- ([\w]+):start -->)\n?(.*?)\n?(<!-- \\2:stop -->)/s", $text, $matches, PREG_SET_ORDER); if ($number == 0) return $text; else unset($item); foreach ($matches as $item) if (empty($data[$item[2]])) $data[$item[2]] = $this->explosion($item[3]); return $data; } I'm sure it will be something stupid and simple that I've overlooked, but that just makes it an easy answer for you I suppose.

    Read the article

  • Correct syntax for matching a string inside a variable against an array

    - by Jamex
    Hi, I have a variable, $var, that contains a string of characters, this is a dynamic variable that contains the values from inputs. $var could be 'abc', or $var could be 'blu', I want to match the string inside variable against an array, and return all the matches. $array = array("blue", "red", "green"); What is the correct syntax for writing the code in php, my rough code is below $match = preg_grep($var, $array); (incorrect syntax of course) I tried to put quotes and escape slashes, but so far no luck. Any suggestion? TIA

    Read the article

  • Replace the surround of an html element with another document

    - by KvanteTore
    I have an html page with (among other things) a Unity3D window. I would like to replace everything on the page without causing the Unity window to reload. I have tried the following jquery-tastic function replaceSurround(keepElem, newElem) { keepElem.siblings().remove(); keepElem.prepend(newElem.prevAll()); keepElem.append(newElem.nextAll()); var keepParent = keepElem.parent(); var newParent = newElem.parent(); if (keepParent && newParent) { replaceSurround(keepParent, newParent); } } where keepElem is an element in the original document and newElem is the corresponding element in the new document, but it did not work very well.

    Read the article

  • RegEx replace query to pick out wiki syntax

    - by Jeremy Thake
    I've got a string of HTML that I need to grab the "[Title|http://www.test.com]" pattern out of e.g. "dafasdfasdf, adfasd. [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad" I need to replace "[Title|http://www.test.com]" this with "Title". What is the best away to approach this? I was getting close with: string test = "dafasdfasdf adfasd [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad "; string p18 = @"(\[.*?|.*?\])"; MatchCollection mc18 = Regex.Matches(test, p18, RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (Match m in mc18) { string value = m.Groups[1].Value; string fulltag = value.Substring(value.IndexOf("["), value.Length - value.IndexOf("[")); Console.WriteLine("text=" + fulltag); } There must be a cleaner way of getting the two values out e.g. the "Title" bit and the url itself. Any suggestions?

    Read the article

  • preg_replace - don't include string if $4 is blank

    - by bradenkeith
    I have this expression: $regex_phone = '/^(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})' .'(?:(?<=\(\d{3})\))? ?(?:(?<=\d{3})[.-])?([2-9]\d{2})' .'[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?$/'; if(!preg_match($regex_phone, $data['phone'])){ $error[] = "Please enter a valid phone number."; }else{ $data['phone'] = preg_replace($regex_phone, '($1) $2-$3 ext.$4', $data['phone']); } That will take a phone number such as: 803-888-8888 ext 2 as well as 803-888-8888 First number formats as: (803) 888-8888 ext.2 -- the desired effect Second number formats as: (803) 888-8888 ext. -- blank extension How can I set it so that if $4 is blank, that ext. won't show? Thanks so much for any help you can offer. I hope this was clear.

    Read the article

  • Items are being replace by another in the Datagridview

    - by stephanie
    When I add the first item in the datagridview its ok but when i add the second one it replace the last item being added. here's my code Private Sub add() Dim i As Integer For i = 0 To DataGridView1.Rows.Count - 1 'DataGridView1.Rows.Add() DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("TransID").Value = txttrans.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("ProductCode").Value = txtprodcode.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("ProductName").Value = cmbprodname.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("Quantity").Value = txtqty.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("Price").Value = txtprc.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("Amount").Value = txtat.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("CustomerName").Value = txtcust.Text DataGridView1.Rows(DataGridView1.RowCount - 1).Cells("Date1").Value = txtdate.Text Next i End Sub And this is in my ADDbutton: Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click Try add() Catch ex As Exception MessageBox.Show(ex.Message) End Try Dim total As Integer For Each row As DataGridViewRow In DataGridView1.Rows total += row.Cells("Amount").Value Next txtamt.Text = total

    Read the article

  • Retain Delimiters when Splitting String

    - by JoeC
    Edit: OK, I can't read, thanks to Col. Shrapnel for the help. If anyone comes here looking for the same thing to be answered... print_r(preg_split('/([\!|\?|\.|\!\?])/', $string, null, PREG_SPLIT_DELIM_CAPTURE)); Is there any way to split a string on a set of delimiters, and retain the position and character(s) of the delimiter after the split? For example, using delimiters of ! ? . !? turning this: $string = 'Hello. A question? How strange! Maybe even surreal!? Who knows.'; into this array('Hello', '.', 'A question', '?', 'How strange', '!', 'Maybe even surreal', '!?', 'Who knows', '.'); Currently I'm trying to use print_r(preg_split('/([\!|\?|\.|\!\?])/', $string)); to capture the delimiters as a subpattern, but I'm not having much luck.

    Read the article

  • Php regular expression to match a div

    - by Thoman
    Hello This is mycode <?php /** * @author Joomlacoders * @copyright 2010 */ $url="http://urlchecker.net/html/demo.html"; $innerHtml=file_get_contents($url); //echo $innerHtml; preg_match_all("{\<div id='news-id-.*d'\>(.*)\</div\>}",$innerHtml,$matches); //<div id='news-id-160346'> var_dump($matches); ?> I want find all content in div id='news-id-160346'. Please help me

    Read the article

  • Regular Expression to match unlimited number of options

    - by Pekka
    I want to be able to parse file paths like this one: /var/www/index.(htm|html|php|shtml) into an ordered array: array("htm", "html", "php", "shtml") and then produce a list of alternatives: /var/www/index.htm /var/www/index.html /var/www/index.php /var/www/index.shtml Right now, I have a preg_match statement that can split two alternatives: preg_match_all ("/\(([^)]*)\|([^)]*)\)/", $path_resource, $matches); Could somebody give me a pointer how to extend this to accept an unlimited number of alternatives (at least two)? Just regarding the regular expression, the rest I can deal with. The rule is: The list needs to start with a ( and close with a ) There must be one | in the list (i.e. at least two alternatives) Any other occurrence(s) of ( or ) are to remain untouched.

    Read the article

  • Excel Macro to find text in cell and insert hyperlink on cell

    - by tnriverfish
    We're managing some system bugs in a web system and setting priority for execs in a spreadsheet. Each of the tickets has a "FD-" and four numbers as the ID. The web system has a hyperlink that has that "FD-####" at the end of the link. The end result would look like this -- http://www.mytickets.com/FD-#### I'd like to run a macro that finds all the FD-#### and inserts a hyperlink on each. There may be multiple FD-#### in a single cell and there will certainly be other text in there. I'd go through each and add the link but there are over 150 or so. Thanks!

    Read the article

  • Highlight text, except html tags

    - by Arjen
    Hey, I'm using the code below to highlight some keywords in a text: $message = str_ireplace($words,'<span class="hightlighted_text">'.$words.'</span>',$message); The text may contain some html tags, for example , etc.. How can I highlight "normal" text, except the text between the html tags? Because when users search for "img" the text will be highlighted and the image doesn't work anymore.

    Read the article

  • preg_match and long strings

    - by aleluja
    Hi, This is the preg_match i am trying to use to find specific text in text file. if (preg_match($regexp,$textFile,$result) > 0) { echo "Found ".$result[0]; } else { echo "Not found"; } However, the result is always Found and nothing more. The result array is empty. Now i read that preg_match can't work with long strings. My text file is about 300KB so thats 300000 characters i guess. I am 100% sure that the searched string is in the text file, and the fact that preg_match function returns value above 0 means it found it, but it didn't place it into the result array somehow. So my question would be, how do i make it work? regexp would be /[specific text]\{(\d*)\}/ so, of course i want to be able to get the number in the parentheses.

    Read the article

  • How would I create a VIM or Vi command to delete all text after a certain character for every line i

    - by Jason Down
    Scenario: I have a text file that has pipe (as in the "|" character) delimited data. Each field of data in the pipe delimited fields can be of variable length, so counting characters won't work (or using some sort of substring function... if that even exists in VIM). Is it possible, using VIM / Vi to delete all data from the second pipe to the end of the line for the entire file? There are approx 150,000 lines, so doing this manually would only be appealing to a masochist... e.g. Change the following lines from: 1111|random sized text 12345|more random data la la la|1111|abcde 2222|random sized text abcdefghijk|la la la la|2222|defgh 3333|random sized text|more random data|33333|ijklmnop to: 1111|random sized text 12345 2222|random sized text abcdefghijk 3333|random sized text I'm sure this can be done somehow... I hope. TIA UPDATE: I should have mentioned that I'm running this on Windows XP, so I don't have access to some of the mentioned *nix commands (CUT is not recognized on Windows).

    Read the article

  • Will html5 and Javascript replace native applications?

    - by nimo
    I recently attended a conference on future of the web and web development and it was a lot of focus on HTML5 and how it will impact the way we look at the web and how we will use it. The majority of the speakers meant that it will replace native application on your desktop as well as in your mobile phone. I agree that you will be able to make a lot of great stuff with the new technology take bespin for example and the <video> and <canvas> tag will be amazing, but will it completely remove the need for native applications? Is there something you cannot do with Javascript and HTML5?

    Read the article

  • preg_match() find all values inside of table?

    - by mathiregister
    hey guys, a curl function returns a string $widget that contains regular html - two divs where the first div holds a table with various values inside of <td>'s. i wonder what's the easiest and best way for me to extract only all the values inside of the <td>'s so i have blank values without the remaining html. any idea what the pattern for the preg_match should look like? thank you.

    Read the article

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