Search Results

Search found 7529 results on 302 pages for 'replace'.

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

  • Replace beginning words

    - by Newbie
    I have the below tables. tblInput Id WordPosition Words -- ----------- ----- 1 1 Hi 1 2 How 1 3 are 1 4 you 2 1 Ok 2 2 This 2 3 is 2 4 me tblReplacement Id ReplacementWords --- ---------------- 1 Hi 2 are 3 Ok 4 This The tblInput holds the list of words while the tblReplacement hold the words that we need to search in the tblInput and if a match is found then we need to replace those. But the problem is that, we need to replace those words if any match is found at the beginning. i.e. in the tblInput, in case of ID 1, the words that will be replaced is only 'Hi' and not 'are' since before 'are', 'How' is there and it is not in the tblReplacement list. in case of Id 2, the words that will be replaced are 'Ok' & 'This'. Since these both words are present in the tblReplacement table and after the first word i.e. 'Ok' is replaced, the second word which is 'This' here comes first in the list of ID category 2 . Since it is available in the tblReplacement, and is the first word now, so this will also be replaced. So the desired output will be Id NewWordsAfterReplacement --- ------------------------ 1 How 1 are 1 you 2 is 2 me My approach so far: ;With Cte1 As( Select t1.Id ,t1.Words ,t2.ReplacementWords From tblInput t1 Cross Join tblReplacement t2) ,Cte2 As( Select Id, NewWordsAfterReplacement = REPLACE(Words,ReplacementWords,'') From Cte1) Select * from Cte2 where NewWordsAfterReplacement <> '' But I am not getting the desired output. It is replacing all the matching words. Urgent help needed*.( SET BASED )* I am using SQL Server 2005. Thanks

    Read the article

  • Python adding elements from string

    - by owca
    I have a string like this "1 1 3 2 1 1 1 2 1 1 1 1 1 1 1 1,5 0,33 0,66 1 0,33 0,66 1 1 2 1 1 2 1 1 2 0,5 0,66 2 1 2 1 1 1 0 1". How to add elements to each other in python ? I've tried : list = [] for x in str.replace(' ', ''): list.append(x) sum = 0 for y in list: sum = sum + double(x) but I'm getting errors constantly.

    Read the article

  • Regex to Match White Space or End of String

    - by Kirk
    I'm trying to find every instance of @username in comment text and replace it with a link. Here's my PHP so far: $comment = preg_replace('/@(.+?)\s/', '<a href="/users/${1}/">@${1}</a> ', $comment); The only problem is the regex is dependent upon there being whitespace after the @username reference. Can anyone help me tweak this so it will also match if it is at the end of the string?

    Read the article

  • grep_replace: unknown modifier

    - by tic
    Let assume that $body is equal to something that does not interest me <!-- start --> some html code <!-- end --> something that does not interest me If I use $body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body); I obtain: Warning: preg_replace() [function.preg-replace]: Unknown modifier '<' How have I to correct?

    Read the article

  • regexp uppercase to lowercase

    - by luccio
    Hi, is it possible to transform regexp pattern match to lowercase? var pattern:RegExp; var str:String = "HI guys"; pattern = /([A-Z]+)/g; str = str.replace(pattern, thisShouldBeLowerCase); Output should look like this: "hi guys" Thx

    Read the article

  • preg_replace, exact opposite of a preg_match

    - by SoLoGHoST
    I need to do a preg_replace for the exact opposite of this preg_match regular expression: preg_match('#^(\w+/){0,2}\w+\.\w+$#', $string); So I need to replace all strings that are not valid with an empty string - '' So it needs to remove the first / and last / if found, and all non-valid characters, that is the only valid characters are A-Z, a-z, 0-9, _, ., and / (if it's not the first or last characters of the string). How can I accomplish this with the preg_replace? Thanks :)

    Read the article

  • Convert URLs into HTML links using sed?

    - by Mike Crittenden
    I'm wondering if it's possible (recommended might be the better word) to use sed to convert URLs into HTML hyperlinks in a document. Therefore, it would look for things like: http://something.com And replace them with <a href="http://something.com">http://something.com</a> Any thoughts? Could the same also be done for email addresses?

    Read the article

  • Remove <p class="classname"> in Javascript?

    - by streetparade
    How can i remove this <p> tag with all its content in javascript? say i have this html code <p class="classname"> <input name="commit" value="Get Value" type="submit"> <span>or Cancel</span> </p> Now i need to replace/remove it in javascript, does anyone know how i can remove it?

    Read the article

  • Java String.replaceAll regex

    - by atomsfat
    I want to replace the first context of web/style/clients.html with the java String.replaceFirst method so I can get: ${pageContext.request.contextPath}/style/clients.html I tried String test = "web/style/clients.html".replaceFirst("^.*?/", "hello/"); And this give me: hello/style/clients.html but when I do String test = "web/style/clients.html".replaceFirst("^.*?/", "${pageContext.request.contextPath}/"); gives me java.lang.IllegalArgumentException: Illegal group reference

    Read the article

  • Escaping escape Characters

    - by Alix Axel
    I'm trying to mimic the json_encode bitmask flags implemented in PHP 5.3.0, here is the string I have: $s = addslashes('O\'Rei"lly'); // O\'Rei\"lly Doing json_encode($str, JSON_HEX_APOS | JSON_HEX_QUOT) outputs the following: "O\\\u0027Rei\\\u0022lly" And I'm currently doing this in PHP versions older than 5.3.0: str_replace(array('\\"', "\\'"), array('\\u0022', '\\\u0027'), json_encode($s)) or str_replace(array('\\"', '\\\''), array('\\u0022', '\\\u0027'), json_encode($s)) Which correctly outputs the same result: "O\\\u0027Rei\\\u0022lly" I'm having trouble understanding why do I need to replace single quotes ('\\\'' or even "\\'" [surrounding quotes excluded]) with '\\\u0027' and not just '\\u0027'.

    Read the article

  • php preg_replace with php code

    - by john
    I have a function that finds a regex thingy, then replaces with php code. I want to have it replace the found regex with php code on the screen, like have it echo out ". except when it echos that in the source, it shows all the

    Read the article

  • preg_replace Pattern

    - by codeworxx
    Hey Guys, i'm not very firm with preg_replace - in other Words i do not really understand - so i hope you can help me. I have a string in a Text like this one: [demo category=1] and want to replace with the Content of Category (id=1) e.g. "This is the Content of my first Category" This is my startpoint Pattern - that's all i have: '/[demo\s*.*?]/i'; Hope you can help? Thanks, Sascha

    Read the article

  • ASP.NET MVC Controller parameter processing

    - by Leonardo
    In my application I have a string parameter called "shop" that is required in all controllers, but it needs to be transformed using code like this: shop = shop.Replace("-", " ").ToLower(); How can I do this globally for all controllers without repeating this line in over and over? Thanks, Leo

    Read the article

  • Can I somehow know which replacement is taking place from within a callback of preg_replace_callback

    - by jayarjo
    I'm using preg_replace_callback to substitute particular tokens within the string. But apart from actual token I need to know as well whether that token was first, second or third in a subject string. Is there any way to access that info? I found an argument $count in preg_replace_callback definition (http://php.net/manual/en/function.preg-replace-callback.php), which counts replacements, but I'm not sure if it is accessible from within callback. Any example of the usage in described context?

    Read the article

  • How to str_replace a section of PHP Code

    - by whatshakin
    $embedCode = <<<EOF getApplicationContent('video','player',array('id' => $iFileId, 'user' => $this->iViewer, 'password' => clear_xss($_COOKIE['memberPassword'])),true) EOF; $name = str_replace($embedCode,"test",$content); I'm trying to replace a section of code with another piece of code. I can do it with smaller strings but once I added the larger strings to $embedCode, it throw an "unexpected T_ENCAPSED_AND_WHITESPACE" error

    Read the article

  • To Search Only title tag for &raquo; using visual studio 2008

    - by Kuldeep Kumar
    i need to update only title tag of my website having around 3000 web pages. i have to replace » with Dash if it is present only in title tag. Please help if there is any way in visual studio 2008 to find a Standard HTML (DOM) Tag. i've done this using dreamweaver Advance text search. but on development machine, only visual studio 2008 is available.

    Read the article

  • php: regex remove bracket in string

    - by apis17
    hi, similiar like this example, http://stackoverflow.com/questions/1336672/php-remove-brackets-contents-from-a-string i have no idea to replace $str = '(ABC)some text' into $str = 'ABC'; currently use $str = preg_replace('/(.)/','',$str); but not works. how to fix this?

    Read the article

  • Replacing text after node

    - by Andrew
    I am trying to remove the "Hide this data" from this XML which is proceeded with the qualifier type="noView" <element version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element version="Local"> <qualifier name="Public" type="noView" /> Hide this data </element> I am using this XSL <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="qualifier"> <xsl:call-template name="replace-noview" /> </xsl:template> <xsl:template name="replace-noview"> <xsl:param name="text" select="@type"/> <xsl:choose> <xsl:when test="contains($text, 'noView')"> <xsl:copy-of select="."/> <xsl:text>DELETED</xsl:text> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> The output I'm getting is <element identifier="ContactName" version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element identifier="ContactName" version="Local"> <qualifier name="Public" type="noView" />DELETED Hide this data </element> I am matching the "noView" attribute and can add the "DELETED" text. However I need to remove the follow "Hide this data" text. The output I would like is <element identifier="ContactName" version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element identifier="ContactName" version="Local"> <qualifier name="Public" type="noView" /> DELETED </element>

    Read the article

  • replacing a path with sed

    - by compie
    How can I use sed to replace this line char * path_list_[1] = { "/some/random/path" }; with this line char * path_list_[2] = { "lib/foo", "lib/bar" }; in a file named source.c Notes: * The path is really random. * Your solution should only change this line in source.c * I'm only interested in a sed oneliner. You can use this Python regex as a starting point: text = re.sub('static const char \* path_list_\[1\] = \{ "[^"]*" \};', 'static const char * path_list_[2] = { "lib/sun", "lib/matlab" };', text)

    Read the article

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