Search Results

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

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

  • 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 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

  • Maven: properties not being substituted

    - by jobrahms
    I'm using a maven plugin for install4j in my project, located here. That plugin lets you pass variables to install4j using the <compilerVariables> section. Here's the relevant section of my pom: <plugin> <groupId>com.google.code.maven-install4j</groupId> <artifactId>maven-install4j-plugin</artifactId> <version>0.1.1</version> <configuration> <executable>${devenv.install4jc}</executable> <configFile>${basedir}/newinstaller/ehd.install4j</configFile> <releaseId>${project.version}</releaseId> <attach>false</attach> <skipOnMissingExecutable>false</skipOnMissingExecutable> <compilerVariables> <property> <name>m2_home</name> <value>${settings.localRepository}</value> </property> </compilerVariables> </configuration> </plugin> The problem is that ${settings.localRepository} is not being substituted with the actual directory when I run the plugin. Here's the command line script that install4j is generating: [INFO] Running the following command for install4j compile: /bin/sh -c /home/zach/install4j/bin/install4jc --release=9.1-SNAPSHOT --destination="/home/zach/projects/java/ehdtrunk/target/install4j" -D m2_home=${settings.localRepository} /home/zach/projects/java/ehdtrunk/newinstaller/ehd.install4j Is this the fault of the plugin? If so, what needs to change to allow the substitution to happen?

    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

  • Reformatting a Java String

    - by Travis
    I have a string that looks like this: CALDARI_STARSHIP_ENGINEERING and I need to edit it to look like Caldari Starship Engineering Unfortunately it's three in the morning and I cannot for the life of me figure this out. I've always had trouble with replacing stuff in strings so any help would be awesome and would help me understand how to do this in the future.

    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

  • SEARCHING AND REPLACING BRACKETS IN A STRING IN ORACLE 10G

    - by Tunde
    hello, Thanks as usual for your prompt and kind suggestions. i am currently developing a function that is meant to execute dynamically created SQL statements. this is done by concatenating the columns and fetching them via cursors. the problem is that when there is a function with a comma between its arguments, the concat concatenates the contents of the functions inclusive. Is it possible to skip contents of every bracket found in a string using REGEXP_SUBTR or REGEXP_REPLACE? Many thanks for the anticipated response.

    Read the article

  • preg_replace pass match through function before replacing

    - by Martin
    This is what i want to do: $line = 'blabla translate("test") blabla'; $line = preg_replace("/(.*?)translate\((.*?)\)(.*?)/","$1".translate("$2")."$3",$line); So the result should be that translate("test") is replaced with the translation of "test". The problem is that translate("$2") passes the string "$2" to the translate function. So translate() tries to translate "$2" instead of "test". Is there some way to pass the value of the match to a function before replacing?

    Read the article

  • rename an html page according to an image within it

    - by Jake
    Hi, firstly I'll give some background regarding the situation. I have a website containing approximately 56k pages each page contain a mapped sketch of a machine part. this machine part is made out of smaller parts which are outlined in the image and hold a certain number. when you hover over the numbers a box with the part item code shows up. I order parts according to this item codes but recently a lot of the items codes have changed, therefore I am looking for a solution. now I own a database with data on all the 56k parts and I want to link the relevant webpage to each record according to the name of the part(a column in my database), the problem is that the webpages names has no logic name that could connect with the part name in any way but the image that is displayed in the page has the exact name of the part. I want to rename all the html files I has according to the Images displayed within them. how can I achieve that without renaming all the 56k pages manually? additionally how can I add the links to all the 56k pages automatically to my database after all the above is done? Thank you for your patience I know it was long.

    Read the article

  • Regular expression

    - by atno
    Hi I have an array that its first element might contains something like [some text, here. That's some text] I'm trying to figure out a pattern to check if such string exists and if not create it but having problem with making the pattern. Here's what I've done so far $pattern = '/^\[*\]$/'; if(preg_match($pattern,$exploded[0])){ $name = array_shift($exploded); }else{ $name = "[Unnamed import] - " .gmdate("His"); } But I always get [Unnamed import] - 032758 even when I'm sure that pattern match

    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

  • Replace CR/LF in a text file only after a certain column

    - by Olav
    I have a large text file I would like to put on my ebook-reader, but the formatting becomes all wrong because all lines are hard wrapped at or before column 80 with CR/LF, and paragraphs/headers are not marked differently, only a single CR/LF there too. What I would like is to replace all CR/LF's after column 75 with a space. That would make most paragraphs continuous. (Not a perfect solution, but a lot better to read.) Is it possible to do this with a regex? Preferably a (linux) perl or sed oneliner, alternatively a Notepad++ regex.

    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

  • Use JavaScript to Replace Classname Value

    - by user1515425
    I want to replace every occurrence of the numbers with the string: ???. Here is an example string: <em>Chelsea</em> 1-4 Atletico Madrid How can I do this in JavaScript? <a href="https://www.google.com/url?sa=t&amp;source=web&amp;cd=9&amp;cad=rja&amp;ved=0CFEQtwIwCA&amp;url=http%3A%2F%2Fwww.whoateallthepies.tv%2Fchelsea%2F137070%2Fsuper-cup-chelsea-1-4-atletico-madrid-falcao-on-fire-as-blues-flop-in-monaco-photos-highlights.html&amp;rct=j&amp;q=chelsea&amp;ei=1odBUImpBIWA0AWM1oC4BA&amp;usg=AFQjCNEwdCCckt15XTkHSAf2fsUnGk9IJg&amp;sig2=IOrD6hfMrviW9ods0DG2dw" class="l" onmousedown="return rwt(this,'','0','','9','AFQjCNEwdCCckt15XTkHSAf2fsUnGk9IJg','IOrD6hfMrviW9ods0DG2dw','0CFEQtwIwCA',null,event)" title="Super Cup: Chelsea 1-4 Atletico Madrid – Falcao On Fire As Blues Flop In Monaco (Photos ...">Super Cup: <em>Chelsea</em> 1-4 Atletico Madrid – Falcao On <b>...</b></a> Thanks in advance.

    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

  • Copy NSArray and replace text items with bool values

    - by Frank Martin
    I utilize a (nested) plist to populate UITableViews where users can select entries at the deepest levels and set a checkmark (or not). I want to save these selections in a same structured list where at the deepest level the NSArray contains bool values instead the text strings that are displayed in the UITableView. So how can i build from a hierarchy like the following: Root - Item 0 (Dictionary) - Group (Dictionary) - Items (NSArray) - Item 0: @"Please check me" (String) a hierarchy like this? Root - Item 0 (Dictionary) - Group (Dictionary) - Items (NSArray) - Item 0: 0 (NSNumber) // NSNumber for bool values I'm trying to create a deep mutable copy and replace the items at the deepest levels but have somehow the feeling that this can be done easier. Thanks for any help with this in advance. Frank

    Read the article

  • PHP regular expression for positive number with 0 or 2 decimal places

    - by Peter
    Hi I am trying to use the following regular expression to check whether a string is a positive number with either zero decimal places, or 2: ^\d+(\.(\d{2}))?$ When I try to match this using preg_match, I get the error: Warning: preg_match(): No ending delimiter '^' found in /Library/WebServer/Documents/lib/forms.php on line 862 What am I doing wrong?

    Read the article

  • Replace images in a DIV using javascript.

    - by Muhammad Sajid
    Hi, I want to show different images in a DIV, the turn of an image depend on a random number. The image name is like 1.gif, 2.gif, .. 6.gif to do that I coded var img = document.createElement("IMG"); img.src = "images/1.gif"; document.getElementById('imgDiv').appendChild(img); but it does not replace the old image how ever it add an another image right in the bottom of first image. syntax for DIV is: <div id="imgDiv" style="width:85px; height:100px; margin:0px 10px 10px 375px;"></div> may u halp me ?

    Read the article

  • Replace a list of emoticons with their images

    - by Damiano
    Hello, I have an array with: emoticons = { ':-)' : 'smile1.gif', ':)' : 'smile2.gif', ':D' : 'smile3.gif' } then i have a variabile with the text. var text = 'this is a simple test :)'; and a variable with the url of the website var url = "http://www.domain.com/"; How to write a function that replace the symbols with their images? The <img> tag result should be: <img src="http://www.domain.com/simple2.gif" /> (I have to concatenate the url varible to the name of the image). THank you very much!

    Read the article

  • Glib hash table replace

    - by Robert
    I'm using GLib Hash Table. I'm trying to get the current value of the key that I found and then increment its value. I'm not quite sure how can I replace the existing value. typedef struct { gchar *key; guint my_int; } my_struct; char *v; v = g_hash_table_lookup(table, my_struct.key); if (v == NULL) g_hash_table_insert(table, g_strdup(my_struct.key), (gpointer)(my_struct.my_int)); else g_hash_table_replace() // here I'd like to do something like current_val+1 Any ideas will be appreciate it.

    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

  • 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

  • Java/Groovy File IO Replacing an Image File with it's own Contents - Why Does This Work?

    - by jboyd
    I have some JPG files that need to be replaced at runtime with a JFIF standardized version of themselves (we are using a vendor that gives us JPG that do not have proper headers so they don't work in certain applications)... I am able to create a new file from the existing image, then get a buffered image from that file and write the contents right back into the file without having to delete it and it works... imageSrcFolder.eachFileMatch ( ~/.*\.jpg/, { BufferedImage bi = ImageIO.read( it ) ImageIO.write( bi, "jpg", it ) }); The question I have is why? Why doesn't the file end up doubled in size? Why don't I have to delete it first? Why am I able to take a file object to an existing file and then treat it as if it were a brand new one? It seems that what I consider to be a "file" is not what the File object in java actually is, or else this wouldn't work at all. My code does exactly what I want it to do, but I'm not convinced it always will... it just seems way too easy

    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 | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >