Search Results

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

Page 10/395 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Help with Perl Regex Recursive Replace One Liner? Replace MySQL comments '--' with '#'

    - by NJTechie
    I have various SQL files with '--' comments and we migrated to the latest version of MySQL and it hates these comments. I want to replace -- with #. I am looking for a recursive, inplace replace one-liner. This is what I have : perl -p -i -e 's/--/# /g' `fgrep -- -- * ` A sample .sql file : use myDB; --did you get an error I get the following error : Unrecognized switch: --did (-h will show valid options). p.s : fgrep skipping 2 dashes was just discussed here if you are interested. Any help is appreciated.

    Read the article

  • Replace text in string with delimeters using Regex

    - by user1057735
    I have a string something like, string str = "(50%silicon +20%!(20%Gold + 80%Silver)| + 30%Alumnium)"; I need a Regular Expression which would Replace the contents in between ! and | with an empty string. The result should be (50%silicon +20% + 30%Alumnium). If the string contains something like (with nested delimiters): string str = "(50%silicon +20%!(80%Gold + 80%Silver + 20%!(20%Iron + 80%Silver)|)| + 30%Alumnium)"; The result should be (50%silicon +20% + 30%Alumnium) - ignoring the nested delimiters. I've tried the following Regex, but it doesn't ignore the nesting: Regex.Replace(str , @"!.+?\|", "", RegexOptions.IgnoreCase);

    Read the article

  • Access VBA remove CR & LF only from the beginning of a text string by searching for them

    - by uZI
    Hi there I need to remove line breaks from the beginning of a memo type records. I dont want to use the replace function as it would remove all line breaks from the record which is not desired. Its only the line breaks at the beginning of the field that I am interested in removing. Furthermore, the my records do not always begin with a line break so I cant really use text positioning, the solution would be to look for line break at the beginning instead of always expecting it at the beginning. click here for a sample of what my data looks like any help will be greatly appreciated

    Read the article

  • JQuery slideToggle replace image src

    - by Rob
    Hi, This function is called when an up/down arrow is clicked to slide hidden div. If the div is hidden, the arrow points down and changes to up when the div is shown. If the div is shown, the arrow points up to hide div and changes to down when the div is closed. I just wanted to know if there was a more efficient way of doing this or if this is the correct way. Thanks. function showInfo(info_id) { var img_id = '#arrow_'+info_id; var div = '#info_'+appointment_id; $(div).slideToggle('normal',function() { if ($(this).is(':visible')) { $(img_id).attr('src',$(img_id).attr('src').replace('_down','_up')); } else { $(img_id).attr('src',$(img_id).attr('src').replace('_up','_down')); } });}

    Read the article

  • Find and replace text in a string using C#

    - by Joey Morani
    Anyone know how I would find & replace text in a string? Basically I have two strings: string firstS = "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABQODxIPDRQSERIXFhQYHzMhHxwcHz8tLyUzSkFOTUlBSEZSXHZkUldvWEZIZoxob3p9hIWET2ORm4+AmnaBhH//2wBDARYXFx8bHzwhITx/VEhUf39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3//"; string secondS = "abcdefg2wBDABQODxIPDRQSERIXFh/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/abcdefg"; I want to search firstS to see if it contains any sequence of characters that's in secondS and then replace it. It also needs to be replaced with the number of replaced characters in squared brackets: [NUMBER-OF-CHARACTERS-REPLACED] For example, because firstS and secondS both contain "2wBDABQODxIPDRQSERIXFh" and "/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/" they would need to be replaced. So then firstS becomes: string firstS = "/9j/4AAQSkZJRgABAQEAYABgAAD/[22]QYHzMhHxwcHz8tLyUzSkFOTUlBSEZSXHZkUldvWEZIZoxob3p9hIWET2ORm4+AmnaBhH//2wBDARYXFx8bHzwhITx/VEhUf39[61]f3//"; Hope that makes sense. I think I could do this with Regex, but I don't like the inefficiency of it. Does anyone know of another, faster way?

    Read the article

  • Create a new output file in ant replace task

    - by Sathish
    Ant replace task does a in-place replacement without creating a new file. The below snippet replaces tokens in any of the *.xml files with the corresponding values from my.properties file. <replace dir="${projects.prj.dir}/config" replacefilterfile="${projects.prj.dir}/my.properties" includes="*.xml" summary="true"/'> I want those *.xml files that had their tokens replaced be created as *.xml.filtered (for e.g.) and still have the original *.xml. Is this possible in Ant with some smart combination of tasks and concepts ?

    Read the article

  • Javascript string.replace with regex

    - by Jimbo
    I want to replace a url querystring parameter with a new value if it already exists or add it on if not. e.g. The current url could be: a. www.mysite.com/whatever.asp?page=5&version=1 OR b. www.mysite.com/whatever.asp?version=1 I need the resulting url to be www.mysite.com/whatever.asp?page=1&version=1 I suspect I can use string.replace with a regex to do this the most intelligent way but am hoping for a little help with it from someone more experienced with regexs :) Thanks!

    Read the article

  • Javascript or jquery replace text

    - by ngreenwood6
    I need to replace some text that is on the page within the body tag. I am using javascript but have jquery available if needed. I basically need to replace test® (test with the registered trademark) with TEST® or tests® with TESTS® and it could even be test with TEST® or tests with TESTS®. I am able to uppercase them but its not liking to work for me with the ® sign, it wants to put duplicates on ones that already have it. Basically anything on the page that has the word test or tests should be TEST® or TESTS® if it is plural. Any help is appreciated.

    Read the article

  • Replace html tag with a certain class

    - by fire
    I am looking for suitable replacement code that allows me replace the content inside of any HTML tag that has a certain class e.g. $class = "blah"; $content = "new content"; $html = '<div class="blah">hello world</div>'; // code to replace, $html now looks like: // <div class="blah">new content</div> Bare in mind that: It wont necessarily be a div, it could be <h2 class="blah"> The class can have more than one class and still needs to be replaced e.g. <div class="foo blah green">hello world</div> I am thinking regular expressions should be able to do this, if not I am open to other suggestions such as using the DOM class (although I would rather avoid this if possible because it has to be PHP4 compatible).

    Read the article

  • Javascript search and replace sequence of characters that contain square brackets

    - by Ruth
    Hello all I'm trying to search for '[EN]' in the string 'Nationality [EN] [ESP]', I want to remove this from the string so I'm using a replace method, code examaple below var str = 'Nationality [EN] [ESP]'; var find = "[EN]"; var regex = new RegExp(find, "g"); alert(str.replace(regex, '')); Since [EN] is identified as a character set this will output the string 'Nationality [] [ESP]' but I want to remove the square brackets aswell. I thought that I could escape them using \ but it didn't work Any advice would be much appreciated

    Read the article

  • PHP str_replace and preg_replace work on one server but not another

    - by retailevolved
    I have a simple function on a php page that takes a url such as: http://myurl.com/mypage.html?param1=value1 and converts it to: http://myurl.com/searchpage.html?param1=value1 All it does it swap out the page.html portion. To do this, I use the following: $currentUrl = $this-getCurrentUrl(); // Grabs the current url, i.e 'http://myurl.com/mypage.html?param1=value1' // Derive a search pattern from the current url $pattern = "/" . str_replace(array("/", ".", "-"), array("\\/", "\\.", "\\-"), $currentUrl) . "/"; // get rid of the 'mypage.html' $newUrl = preg_replace($pattern, 'http://myurl.com/', $currentUrl); // replace the question mark with the correct page $newUrl = str_replace("/?", "/searchpage.html?", $newUrl); The above code is not the exact code but is a good representation. It works beautifully on one server, but when I push to production, the preg_replace does not work. I originally attempted to use str_replace. It also works on my local development machine, but not on the production server. I have confirmed that the URL variables are coming in correctly. Any ideas?

    Read the article

  • How do I pass a variable number of parameters along with a callback function?

    - by Bungle
    I'm using a function to lazy-load the Sizzle selector engine (used by jQuery): var sizzle_loaded; // load the Sizzle script function load_sizzle(module_name) { var script; // load Sizzle script and set up 'onload' and 'onreadystatechange' event // handlers to ensure that external script is loaded before dependent // code is executed script = document.createElement('script'); script.src = 'sizzle.min.js'; script.onload = function() { sizzle_loaded = true; gather_content(module_name); }; script.onreadystatechange = function() { if ((script.readyState === 'loaded' || script.readyState === 'complete') && !sizzle_loaded) { sizzle_loaded = true; gather_content(module_name); } }; // append script to the document document.getElementsByTagName('head')[0].appendChild(script); } I set the onload and onreadystatechange event handlers, as well as the sizzle_loaded flag to call another function (gather_content()) as soon as Sizzle has loaded. All of this is needed to do this in a cross-browser way. Until now, my project only had to lazy-load Sizzle at one point in the script, so I was able to just hard-code the gather_content() function call into the load_sizzle() function. However, I now need to lazy-load Sizzle at two different points in the script, and call a different function either time once it's loaded. My first instinct was to modify the function to accept a callback function: var sizzle_loaded; // load the Sizzle script function load_sizzle(module_name, callback) { var script; // load Sizzle script and set up 'onload' and 'onreadystatechange' event // handlers to ensure that external script is loaded before dependent // code is executed script = document.createElement('script'); script.src = 'sizzle.min.js'; script.onload = function() { sizzle_loaded = true; callback(module_name); }; script.onreadystatechange = function() { if ((script.readyState === 'loaded' || script.readyState === 'complete') && !sizzle_loaded) { sizzle_loaded = true; callback(module_name); } }; // append script to the document document.getElementsByTagName('head')[0].appendChild(script); } Then, I could just call it like this: load_sizzle(module_name, gather_content); However, the other callback function that I need to use takes more parameters than gather_content() does. How can I modify my function so that I can specify a variable number of parameters, to be passed with the callback function? Or, am I going about this the wrong way? Ultimately, I just want to load Sizzle, then call any function that I need to (with any arguments that it needs) once it's done loading. Thanks for any help!

    Read the article

  • C# Find and Replace RegEx with wildcard search and addition of value

    - by fraXis
    Hello, The below code is from my other questions that I have asked here on SO. Everyone has been so helpful and I almost have a grasp with regards to RegEx but I ran into another hurdle. This is what I basically need to do in a nutshell. I need to take this line that is in a text file that I load into my content variable: X17.8Y-1.Z0.1G0H1E1 I need to do a wildcard search for the X value, Y value, Z value, and H value. When I am done, I need this written back to my text file (I know how to create the text file so that is not the problem). X17.8Y-1.G54G0T2 G43Z0.1H1M08 I have code that the kind users here have given me, except I need to create the T value at the end of the first line, and use the value from the H and increment it by 1 for the T value. For example: X17.8Y-1.Z0.1G0H5E1 would translate as: X17.8Y-1.G54G0T6 G43Z0.1H5M08 The T value is 6 because the H value is 5. I have code that does everything (does two RegEx functions and separates the line of code into two new lines and adds some new G values). But I don't know how to add the T value back into the first line and increment it by 1 of the H value. Here is my code: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); content = Regex.Replace(content, @"X[-\d.]+Y[-\d.]+", "$0G54G0"); content = Regex.Replace(content, @"(Z(?:\d*\.)?\d+)[^H]*G0(H(?:\d*\.)?\d+)\w*", "\nG43$1$2M08"); //This must be created on a new line This code works great at taking: X17.8Y-1.Z0.1G0H5E1 and turning it into: X17.8Y-1.G54G0 G43Z0.1H5M08 but I need it turned into this: X17.8Y-1.G54G0T6 G43Z0.1H5M08 (notice the T value is added to the first line, which is the H value +1 (T = H + 1). Can someone please modify my RegEx statement so I can do this automatically? I tried to combine my two RegEx statements into one line but I failed miserably. Thanks so much, Shawn

    Read the article

  • Find and Replace RegEx with wildcard search and addition of value

    - by fraXis
    The below code is from my other questions that I have asked here on SO. Everyone has been so helpful and I almost have a grasp with regards to RegEx but I ran into another hurdle. This is what I basically need to do in a nutshell. I need to take this line that is in a text file that I load into my content variable: X17.8Y-1.Z0.1G0H1E1 I need to do a wildcard search for the X value, Y value, Z value, and H value. When I am done, I need this written back to my text file (I know how to create the text file so that is not the problem). X17.8Y-1.G54G0T2 G43Z0.1H1M08 I have code that the kind users here have given me, except I need to create the T value at the end of the first line, and use the value from the H and increment it by 1 for the T value. For example: X17.8Y-1.Z0.1G0H5E1 would translate as: X17.8Y-1.G54G0T6 G43Z0.1H5M08 The T value is 6 because the H value is 5. I have code that does everything (does two RegEx functions and separates the line of code into two new lines and adds some new G values). But I don't know how to add the T value back into the first line and increment it by 1 of the H value. Here is my code: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); content = Regex.Replace(content, @"X[-\d.]+Y[-\d.]+", "$0G54G0"); content = Regex.Replace(content, @"(Z(?:\d*\.)?\d+)[^H]*G0(H(?:\d*\.)?\d+)\w*", "\nG43$1$2M08"); //This must be created on a new line This code works great at taking: X17.8Y-1.Z0.1G0H5E1 and turning it into: X17.8Y-1.G54G0 G43Z0.1H5M08 but I need it turned into this: X17.8Y-1.G54G0T6 G43Z0.1H5M08 (notice the T value is added to the first line, which is the H value +1 (T = H + 1). Can someone please modify my RegEx statement so I can do this automatically? I tried to combine my two RegEx statements into one line but I failed miserably.

    Read the article

  • Find & Replace - using a Regex for this?

    - by Jack W-H
    Hey folks. Regexs make me cry, so, I came here for help. I'm looking for some tips on Find & Replace in Panic's Coda. I know the F&R is pretty advance but I'm just looking for the best way to do this. I'm trying to rewrite a 'template engine' (very basic) I have going on with a webapp I'm coding in PHP (CodeIgniter). Currently I'm calling my template like so: $this->load->view('subviews/template/headerview'); $this->load->view('subviews/template/menuview'); $this->load->view('subviews/template/sidebar'); $this->load->view('The-View-I-Want-To-Load'); // This is the important line $this->load->view('subviews/template/footerview'); However it's inefficient using five lines of code every time I want to load up a different page, in every different controller. So I rewrote it like this: $data['view'] = 'The-View-I-Want-To-Load'; $this->load->view('template',$data); That way if I need to make any major changes to the design it can easily be done from the template.php view file (which contains the header, menu, sidebar views etc. etc.). However I use the previous 5-lines all over the place in many different controllers and functions. So, my question is --- How can I find and replace the old template engine (5 lines of code) for the new one - substituting in the name of the view in the important, unique line for the one in $data['view]? Does that make any sense?! If not I'll try and rephrase! I mean, is there a way of doing this via a Regex or something? Or am I on completely the wrong lines here? Thanks for your help Jack

    Read the article

  • Find and Replace with Notepad++

    - by Levi
    I have a document that was converted from PDF to HTML for use on a company website to be referenced and indexed for search. I'm attempting to format the converted document to meet my needs and in doing so I am attempting to clean up some of the junk that was pulled over from when it was a PDF such as page numbers, headers, and footers. luckily all of these lines that need to be removed are in blocks of 4 lines unfortunately they are not exactly the same therefore cannot be removed with a simple literal replace. The lines contain numbers which are incremental as they correlate with the pages. How can I remove the following example from my html file. Title<br> 10<br> <hr> <A name=11></a>Footer<br> I've tried many different regular expression attempts but as my skill in that area is limited I can't find the proper syntax. I'm sure i'm missing something fairly easy as it would seem all I need is a wildcard replace for the two numbers in the code and the rest is literal. any help is apprciated

    Read the article

  • batch: replace a line in a text file

    - by sasamimasas
    I'm trying to replace this line: # forward-socks5 / 127.0.0.1:9050 . with this one: forward-socks5 / 127.0.0.1:9050 . this line belongs to a config file that has to be enabled (UN-commented) by deleting the # sign from the beginning and I could not thought of a better way other than replacing the line with another without the # sign. any other thoughts or ways would be very useful. btw, the spaces before the text are there also.I have pasted the text as it was in the original file. thanks in advance EDIT: I have somehow managed to do the line addition and removing using two peaces of code that I've found. my only problem is that the following code removes every bit of exclamation in the output file! @echo off :Variables SETLOCAL ENABLEDELAYEDEXPANSION set InputFile=config.txt set OutputFile=config-new.txt set _strFind=# forward-socks5 / 127.0.0.1:9050 . set _strInsert= forward-socks5 / 127.0.0.1:9050 . set i=0 :Replace for /f "usebackq tokens=1 delims=[]" %%A in (`find /n "%_strFind%" "%InputFile%"`) do (set _strNum=%%A) for /f "usebackq delims=" %%A in ("%InputFile%") do ( set /a i = !i! + 1 echo %%A>>"%OutputFile%" if [!i!] == [%_strNum%] (echo %_strInsert%>>"%OutputFile%") ) type %OutputFile% | findstr /i /v /c:"%_strFind%">config-new2.txt I was wondering if there is any way to do both the find/delete/add line in one step (not two steps as mine)...

    Read the article

  • Javascript and backslashes replace

    - by Frankie
    here is my string: var str = "This is my \string"; This is my code: var replaced = str.replace("/\\/", "\\\\"); I can't get my output to be: "This is my \\string" I have tried every combination I can think of for the regular expression and the replacement value. Any help is appreciated!

    Read the article

  • Regular expression replace a word by a link

    - by AnhTu
    I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link. Example: i'm living <a href="Paris" atl="Paris link">in Paris</a>, near Paris <a href="gare">Gare du Nord</a>, i love Paris. would become i'm living.........near <a href="">Paris</a>..........i love <a href="">Paris</a>.

    Read the article

  • Telerik RadEditor Find & Replace in HTML View

    - by Jim
    We use Telerik's RadEditor for our content management system's WYSIWYG editor. We need the find & replace functionality that is in the WYSIWYG editor to also be in the HTML editor. The editor is pretty customizable, anyone know if there is a way to enable this or hack it in?

    Read the article

  • replace a whole page useing GreaseMonkey

    - by RYan
    is there a way to replace a whole web page using GreaseMonkey? basically a redirection but the address bar still shows the original address. i want the original address to show, but i want to load a modified web page from my hard drive without anyone knowing. thanks

    Read the article

  • Javascript replace

    - by Webby
    Hello struggling here guys.. Is it possible to string replace anything between the the first forward slashes with "" but keep the rest? e.g. var would be string "/anything-here-this-needs-to-be-replaced123/but-keep-this"; would end up like this string "/but-keep-this"; Hope that made sence

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >