Search Results

Search found 9447 results on 378 pages for 'str replace'.

Page 22/378 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Could someone please explain this REGEX?

    - by NJTechGuy
    if($title =~ s/(\s|^|,|\/|;|\|)$replace(\s|$|,|\/|;|\|)//ig) $title can be a set of titles ranging from President, MD, COO, CEO,... $replace can be (shareholder), (Owner) or the like. I keep getting this error. I have checked for improperly balanced '(', ')', no dice :( Unmatched ) in regex; marked by <-- HERE in m/(\s|^|,|/|;|\|)Owner) <-- HERE (\s|$|,|/|;|\|)/ If you could tell me what the regex does, that had be awesome. It strips those symbols is it? Sorry long day at work. Thanks guys!

    Read the article

  • Force 'Replace Into' to use a certain index

    - by Bobby
    I have a MySQL (5.0) table with 3 rows which are considered a combined Unique Index: CREATE TABLE `test`.`table_a` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `field1` varchar(5) COLLATE latin1_swedish_ci NOT NULL DEFAULT '', `field2` varchar(5) COLLATE latin1_swedish_ci NOT NULL DEFAULT '', `field3` varchar(5) COLLATE latin1_swedish_ci NOT NULL DEFAULT '', PRIMARY KEY (`Id`), INDEX `IdxUnqiue` (`field1`(5),`field2`(5),`field3`(5)) ) ENGINE=MyISAM; This table should be filled with a REPLACE INTO query: REPLACE INTO table_a ( Field1, Field2, Field3 ) VALUES ( "Test1", "Test2", "Test3" ) The behavior I'd like to see is that this query always overrides the previous inserted row, because IdxUnique is...ahm, triggered. But unfortunately, there's still the primary index which seems to kick in and always inserts a new row. What I get: Query was executed 3 times: +---Id---+---Field1---+---Field2---+---Field3---+ | 1 | Test1 | Test2 | Test2 | | 2 | Test1 | Test2 | Test2 | | 3 | Test1 | Test2 | Test2 | +--------+------------+------------+------------+ What I want: Query was executed 3 times: +---Id---+---Field1---+---Field2---+---Field3---+ | 3 | Test1 | Test2 | Test2 | +--------+------------+------------+------------+ So, can I tell REPLACE INTO to use just a certain Index or to consider one 'more inportant' then another?

    Read the article

  • How do I create regex groups for replacement?

    - by resting
    I have this sample string: Image: SGD$45.32 SKU: 3f3f3 dfdfd grg4t BP 6yhf Pack Size: 1000's Color: Green Price: SGD$45.32 SGD$45... I would like to remove all the prices namely: SGD$45.32 Price: SGD$45.32 SGD$45 I have this expression thats supposed to match the 3 groups: $pattern = '/(Price.+\sSGD\$\d+\.\d{2})(SGD\$\d+\.\d{2})(SGD\$\d+)/'; $new_snippet = preg_replace($pattern, '', $snippet);` But apparently its not working. It works if I replace a single group at a time. But, I'd like to know if it possible to replace all possible matching groups with a single statement. Tried preg_match_all($pattern, $snippet, $matches); to show matches based on the above pattern, but no matches are found if I put all 3 groups together.

    Read the article

  • jQuery click event to make a div slide down and push next div out of viewport

    - by Josh
    I'm trying to figure out how to make jQuery slide #content2 down and replace content1 with it while making it look like #content1 is actually being pushed down by #content1 removing it from view... Then the same button that was clicked to make #content2 replace #content1 would also need to do the reverse effect by replacing #content2 with #content1 making them slide up and push each other out of the way... I'm not all that great with jQuery so I'm sure I've gone about this the wrong way, but here's what I've tried: $(document).ready(function() { $('#click').click(function() { if($('#content1').is(':visible')) { $('#content1').slideUp(); } else { $('#content2').slideDown(); } }).click(function() { if($('#content1').is(':visible')) { $('#content2').slideDown(); } else { $('#content1').slideUp(); } }); });

    Read the article

  • How to replace strings with javascript?

    - by Damiano
    Hello everybody, I have this function: function emoticons(text){ var url = "http://www.domain.it/images/smilies/"; var emt = { ":D" : 'icon_e_biggrin.gif', ":-D" : 'icon_e_biggrin.gif', ":)" : 'icon_e_smile.gif', ":-)" : 'icon_e_smile.gif', ";)" : 'icon_e_wink.gif', "';-)" : 'icon_e_wink.gif', ":(" : 'icon_e_sad.gif', ":-(" : 'icon_e_sad.gif', ":o" : 'icon_e_surprised.gif', ":?" : 'icon_e_confused.gif', "8-)" : 'icon_cool.gif', ":x" : 'icon_mad.gif', ":P" : 'icon_razz.gif' }; for (smile in emt){ text = text.replace(smile, '<img src="' + url + emt[smile] + '" class="emoticons" />'); } return (text); } As you know .replace() convert the first occurence, how to replace more then one emoticon inside the text? How to change this function? Thank you very much!

    Read the article

  • PHP, what is the better choice for removing a known string?

    - by Brook Julias
    I am looking to search for and replace a known string from within another string. Should I use str_replace() or ereg_replace()? The string to be replaced would be something similar to [+qStr+], [+bqID+], or [+aID+] and it would be being searched for in a code chunk similar to this: <li> [+qStr+] <ol class="mcAlpha"> <li><input type="radio" name="[+bqID+]" id="[+bqID+]_[+aID+]" value="[+aID+]" /><label for="[+bqID+]_[+aID+]">[+aStr+]</label></li> </ol> </li> I would be replacing the strings with the results from a MySQL query, and be performing this action or similar up to 200 times at a time. Which function str_replace() or ereg_replace() would be the easiest and/or quickest method to take.

    Read the article

  • Set a script to automatically detect character encoding in a plain-text-file in Python?

    - by Haidon
    I've set up a script that basically does a large-scale find-and-replace on a plain text document. At the moment it works fine with ASCII, UTF-8, and UTF-16 (and possibly others, but I've only tested these three) encoded documents so long as the encoding is specified inside the script (the example code below specifies UTF-16). Is there a way to make the script automatically detect which of these character encodings is being used in the input file and automatically set the character encoding of the output file the same as the encoding used on the input file? findreplace = [ ('term1', 'term2'), ] inF = open(infile,'rb') s=unicode(inF.read(),'utf-16') inF.close() for couple in findreplace: outtext=s.replace(couple[0],couple[1]) s=outtext outF = open(outFile,'wb') outF.write(outtext.encode('utf-16')) outF.close() Thanks!

    Read the article

  • RegEx to replace html entities

    - by DeltaFox
    Hi, all. I'm looking for a way to replace the bullet character in Greasemonkey. I assume a Regular Expression will do the trick, but I'm not as well-versed in it as many of you. For example, "SampleSite.com • Page Title" becoming "SampleSite.com Page Title". The issue is that the character has already been parsed by the time Greasemonkey has gotten to it, and I don't know how to make it recognize the symbol. I've tried these so far, but they haven't worked: newTitle = document.title.replace(/•/g, ""); newTitle = document.title.replace("•", ""); //just for grins, but didn't work anyway

    Read the article

  • asp.net regex to find anchor tags and replace their url

    - by ace
    Hi -i'm trying to find all the anchor tags and appending the href value with a variable. for example <a href="/page.aspx">link</a> will become <a href="/page.aspx?id=2"> <A hRef='http://www.google.com'><img src='pic.jpg'></a> will become <A hRef='http://www.google.com?id=2'><img src='pic.jpg'></a> I'm able to match all the anchor tags and href values using regex, then i manually replace the values using string.replace, however i dont think its the efficient way to do this. Is there a solution where i can use something like regex.replace(html,newurlvalue)

    Read the article

  • js regex replace multiple words

    - by Raghav
    I need to replace ${conferance name} with ABC, ${conference day} with Monday in the following sentence. Could some one help me with the regex. var text = "<td>${conference name}</td><td>${conference day}</td>" var list = ["${conferance name}", "${conference day}" ] for (var j = 1; j < list.length; j++) { //Extracting the col name var colName = list[j].split("${"); colName = colName.split("}")[0]; //Replacing the col name text = text.replace(new RegExp('\\$\\{' + colName + '\\}', 'g'), "ABC"); } The above code repalces fine if i have ${conference_name}, but it fails when i have a space in between. The list is a dynamic array. And the Replace statements are also dynamic. I just simulated them as objects here for fitting them in the Regex Statement. Thanks in Advance.

    Read the article

  • How do I convert text to hyperlinks in C#?

    - by EmilyM
    I am very very very new to C# and ASP.NET development. What I'd like to do is a find-and-replace for certain words appearing in the body text of a web page. Every time a certain word appears in the body text, I'd like to convert that word into a hyperlink that links to another page on our site. I have no idea where to even start with this. I've found code for doing find-and-replace in C#, but I haven't found any help for just reading through a document, finding certain strings, and changing them into different strings.

    Read the article

  • mysql replace matching but not changing

    - by alex
    I've used mysql's update replace function before, but even though I think I'm following the same syntax, I can't get this to work-it matches the rows, but doesn't replace. Here's what I'm trying to do: mysql> update contained_widgets set preference_values = replace(preference_values, '<li><a_href="/enewsletter"><span class="not-tc">eNewsletter</span></a></li>', '<li><a_href="/enewsletter"><span class="not-tc">eNewsletter</span></a></li> <li> <a_href="/projects"><span class="not-tc">Projects</span></a></li>'); Query OK, 0 rows affected (0.00 sec) Rows matched: 77 Changed: 0 Warnings: 0 I don't see what I'm missing. Any help is appreciated. I edited "a " to "a_" because the site thinks I'm posting spam links otherwise.

    Read the article

  • Resolve bash variable containted in another variable

    - by kogut
    I have code like that: TEXT_TO_FILTER='I would like to replace this $var to proper value' var=variable All I want to get is: TEXT_AFTER_FILTERED="I'd like to replace this variable to proper value" So I did: TEXT_AFTER_FILTERED=`eval echo $TEXT_TO_FILTER` TEXT_AFTER_FILTERED=`eval echo $(eval echo $TEXT_TO_FILTER)` Or even more weirder things, but without any effects. I remember that someday I had similar problem and I did something like that: cat << EOF > tmp.sh echo $TEXT_TO_FILTER EOF chmod +x tmp.sh TEXT_AFTER_FILTERED=`. tmp.sh` But this solution seems to be to much complex. Have any of You heard about easier solution?

    Read the article

  • Find all html characters in drop-down option text and replace them via jQuery

    - by Jon Harding
    I have a dropdown menu that pulls in text from a database column. The database column can include HTML mark-up. In the drop-down I obviously don't need that in the text. I am working on some jquery and it partially accomplished what I'm looking for. However, it seems to only be replacing the first instance of each character $('select option').each(function() { this.text = this.text.replace('&nbsp;', ' '); this.text = this.text.replace('<div>', '' ); this.text = this.text.replace('</div>', '' ); }); Here is the HTML for the drop-down: <select name="ctl00$SubPageBody$ClassList" id="ctl00_SubPageBody_ClassList"> <option value="196">Four Week Series: July 19, 2012, 11:00am-12:00pm&<div>July 26, 2012, 11:00am-12:00pm&nbsp;</div><div>August 2, 2012, 11:00am-12:00pm</div><div>August 9, 2012, 11:00am-12:00pm</div></option> </select>

    Read the article

  • How to replace plain URLs with links?

    - by Sergio del Amo
    I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match. How I can replace all the URL? I guess I should be using the exec command, but I did not really figure how to do it. function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; return text.replace(exp,"<a href='$1'>$1</a>"); }

    Read the article

  • replace capturing group

    - by Don
    Hi, If I have a regex with a capturing group, e.g. foo(_+f). If I match this against a string and want to replace the first capturing group in all matches with baz so that foo___f blah foo________f is converted to: foobaz blah foobaz There doesn't appear to be any easy way to do this using the standard libraries. If I use Matcher.replaceAll() this will replace all matches of the entire pattern and convert the string to baz blah baz Obviously I can just iterate through the matches, store the start and end index of each capturing group, then go back and replace them, but is there an easier way? Thanks, Don

    Read the article

  • Javascript replace using regexp

    - by netcrash
    <input type="text" value="[tabelas][something][oas]" id="allInput"> <script type="text/javascript"> allInput = document.getElementById('allInput'); var nivel = new Array('tabelas', 'produto'); for (var i =0; i < nivel.length ; i++ ) { alert(" oi => " + allInput.value + " <-- " + nivel[i]) ; var re = new RegExp("^\[" + nivel[i] + "\]\[.+\].+", "g"); alert(re); allInput.value = allInput.value.replace( re, "OLA"); alert(" oi 2 => " + allInput.value + " <-- " + nivel[i]) ; } </script> Basically I whant to replace "something2 in the [tabelas][something][otherfield] by a number of quantity, I have been playing with regexp and had different results from this using .replace(/expression/,xxx ) and new RegExp() . Best regards and thank you for any help.

    Read the article

  • Java replace all capturing groups

    - by Don
    Hi, If I have a regex with a capturing group, e.g. foo(g.*f). If I match this against a string and want to replace the first capturing group in all matches with baz so that foog___f blah foog________f is converted to: foobaz blah foobaz There doesn't appear to be any easy way to do this using the standard libraries, because the Matcher.replaceAll() method will only replace all matches of the entire pattern, am I missing something? Obviously I can just iterate through the matches, store the start and end index of each capturing group, then go back and replace them, but is there an easier way? Thanks, Don

    Read the article

  • Dynamically replace HTML element in UIWebView

    - by Skie
    I have some HTML loaded in WebView like this: <html><head></head><body>before <myTag>Content</myTag> after</body></html> I want to replace element myTag with custom text so it should look like: <html><head></head><body>before ____MY_CUSTOM_TEXT___ after</body></html> Also I can't change initial HTML. How I can do this with JavaScript? My not finished code: var elements = document.getElementsByTagName( 'myTag' ); var firstElement = elements[0]; var parentElement = firstElement.parentNode; var html = parentElement.innerHTML; parentElement.innerHTML = html.replace(?????, '____MY_CUSTOM_TEXT___'); I don't know how to get string value of element to replace (?????).

    Read the article

  • How can I search for the dot character using the search command?

    - by lk
    I'm trying to use the Search command in Vim: :Rs/F/T/X R = range F = text to find T = text to replace with X = options But, when I want to search for the "." (dot character) I'm getting some problems. The task: Replace all occurences of " ." (space dot) for "" (greater-than) So, first I tried this: :%s/ ./>/g But this changed me all the " ." (space ANY-CHARACTER) to the "" character. Then I remembered that the dot character is a special one, so I tried this: :%s/ \./>/g But vim threw me an error: E486 Can't find pattern " \." And finally I tried this crazy thing: :%s/" ."/>/g and this :%s/" \."/>/g But I got the same result: E486 Can't find pattern... So, how can I search for the dot character using the search command? PS: Sorry for my poor Enlish.

    Read the article

  • Saving substrings using Regular Expressions

    - by user362971
    I'm new to regular expressions in Java (or any language, for that matter) and I'm wanting to do a find using them. The tricky part that I don't understand how to do is replace something inside the string that matches. For example, if the line I'm looking for is Person item6 [can {item thing [wrap]}] I'm able to write a regex that finds that line, but finding what the word "thing" is (as it may differ among different lines) is my problem. I may want to either replace that word with something else or save it in a variable for later. Is there any easy way to do this using Java's regex engine?

    Read the article

  • Javascript: How to escape Unicode Chars

    - by user293006
    JSON String: { "id":31896, "name":"Zickey attitude - McKinley, La Rosi\u00e8re, 21 ao\u00fbt 2006", ... } this causes an unterminated string in javascript. my focus on solution is: data.replace(/(\S)\1(\1)+/g, ''); or data.replace(/\u([0-9A-Z])/, ''); any ideas/solution? example: http://api.jamendo.com/get2/id+name+url+stream+album_name+album_url+album_id+artist_id+artist_name/track/jsonpretty/track_album+album_artist/?n=13&order=ratingmonth_desc&tag_idstr=jazz last node is the problem, fyi. (/\u([0-9A-Z])/, '\1');

    Read the article

  • How to use window.location.replace javascript?

    - by william
    My URLs http://www.mysite.com/folder1/page1.aspx http://www.mysite.com/folder1/page1.aspx?id=1 http://www.mysite.com/folder1/page1.aspx?id=1&dt=20111128 Redirecting Page http://www.mysite.com/folder1/page2.aspx I want to redirect from page1.aspx to page2.aspx How to write a javascript in page1.aspx? window.location.replace("/page2.aspx"); window.location.replace("../page2.aspx"); window.location.replace("~/page2.aspx"); First 2 gave me this. http://www.mysite.com/page2.aspx Last 1 gave me this. http://www.mysite.com/folder1/~/page2.aspx What is the correct way to use?

    Read the article

  • How to use mod_rewrite to change external incoming images to local images?

    - by STRiDOR
    Hi, I'm trying to figure out how to use mod_rewrite so that I can replace linked images (coming in externally) and use local ones instead. Why am I doing this? I have a plugin which I'm integrating into my site, which uses ugly external images as buttons, and I want to redo these buttons to match my site. The links come in externally and are not embedded in a plugin php somewhere, so I figure there might be some way of using mod_rewrite to intercept and replace the incoming links. I hope someone can help, thanks!

    Read the article

  • Django store regular expression in DB which then gets evaluated on page

    - by John
    Hi, I want to store a number of url patterns in my django model which a user can provide parameters to which will create a url. For example I might store these 3 urls in my db where %s is the variable parameter provided by the user: www.thisissomewebsite.com?param=%s www.anotherurl/%s/ www.lastexample.co.uk?param1=%s&fixedparam=2 As you can see from these examples the parameter can appear anywhere in the string and not in a fixed position. I have 2 models, one holds the urls and one holds the variables: class URLPatterns(models.Model): pattern = models.CharField(max_length=255) class URLVariables(models.Model): pattern = models.ForeignKey(URLPatterns) param = models.CharField(max_length=255) What would be the best way to generate these urls by replacing the %s with the variable in the database. would it just be a simple replace on the string e.g: urlvariable = URLVariable.objects.get(pk=1) pattern = url.pattern url = pattern.replace("%s", urlvariable.param) or is there a better way? Thanks

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >