Search Results

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

Page 46/395 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • sed: replace only the first range of numbers

    - by Marit Hoen
    Imagine I have an input file like this: INSERT INTO video_item_theme VALUES('9', '29'); INSERT INTO video_item_theme VALUES('19', '312'); INSERT INTO video_item_theme VALUES('414', '1'); And I wish to add 10000 to only the first range of numbers, so I end up with something like this: INSERT INTO video_item_theme VALUES('10009', '29'); INSERT INTO video_item_theme VALUES('10019', '312'); INSERT INTO video_item_theme VALUES('10414', '1'); My approach would be to prefix "1000" to one digit numbers, "100" Something like...: sed 's/[0-9]\{2\}/10&/g' ... isn't very helpful, since it changes each occurance of two numbers, not only in the first occurance of numbers: INSERT INTO video_item_theme VALUES('9', '10029'); INSERT INTO video_item_theme VALUES('10019', '100312'); INSERT INTO video_item_theme VALUES('100414', '1');

    Read the article

  • Replace Certificate using Plesk 11

    - by Lambda Dusk
    I am not an admin, but a programmer. But how it is, if you're the only guy who knows about computers, everyone shoves those tasks to you. A certificate of a domain recently expired. The domains are managed using Plesk 11, on a Linux system, Apache2.2. I was given a new certificate from the host, and it is one single .pem file. However, Plesk asks me for a .crt file, a private key and some CA file. I have neither, only this single .pem file the host claims to be the certificate. Since I myself never did anything with SSL certificates, I would really appreciate if anyone can tell me what to do with this file and how to properly add a new one so the old one can be removed.

    Read the article

  • rsync invocation to replace symlinks pointing to source?

    - by bdbaddog
    Currently I'm moving a big filesystem to a new server as the original fileserver is no longer able to handle the filesystem writes. To make this quick I made symlinks at the target filesystem pointing to the original filesystem. Initially: /company/release (mountpoint of the original filesystem) After migration: /company/release.old (points to original filesystem after automount map update) /company/release (points to new fileserver/filesystem after automount map update) In /company/release there are symlinks like the following: /company/release/product-1.0.tar.gz - /company/release.old/product-1.0.tar.gz /company/release/product-1.0 - /company/release.old/product-1.0 (this is a tree of files) Using symlinks allowed me to move the writes to the new filesystem quickly. Now I'd like to slowly migrate the existing files and directories to the new filesystem. The problem I'm running into is that since the symlinks point back at the original files rsync doesn't see any difference and so it doesn't actually copy the file(s) or directory(s) and remove/overwrite the symlinks. Is there a set of rsync flags which will do what I want?

    Read the article

  • (S)FTP only replace older file

    - by PeterJCLaw
    I'm looking for a way to have (S)FTP only copy across a file if it's newer than the one already on the server. Ideally it would spit an error message listing the files that failed (but allow the others). SSH and SCP aren't available, otherwise I'd script something using those.

    Read the article

  • Fixing up Configurations in BizTalk Solution Files

    - by Elton Stoneman
    Just a quick one this, but useful for mature BizTalk solutions, where over time the configuration settings can get confused, meaning Debug configurations building in Release mode, or Deployment configurations building in Development mode. That can cause issues in the build which aren't obvious, so it's good to fix up the configurations. It's time-consuming in VS or in a text editor, so this bit of PowerShell may come in useful - just substitute your own solution path in the $path variable: $path = 'C:\x\y\z\x.y.z.Integration.sln' $backupPath = [System.String]::Format('{0}.bak', $path) [System.IO.File]::Copy($path, $backupPath, $True) $sln = [System.IO.File]::ReadAllText($path)   $sln = $sln.Replace('.Debug|.NET.Build.0 = Deployment|.NET', '.Debug|.NET.Build.0 = Development|.NET') $sln = $sln.Replace('.Debug|.NET.Deploy.0 = Deployment|.NET', '.Debug|.NET.Deploy.0 = Development|.NET') $sln = $sln.Replace('.Debug|Any CPU.ActiveCfg = Deployment|.NET', '.Debug|Any CPU.ActiveCfg = Development|.NET') $sln = $sln.Replace('.Deployment|.NET.ActiveCfg = Debug|Any CPU', '.Deployment|.NET.ActiveCfg = Release|Any CPU') $sln = $sln.Replace('.Deployment|Any CPU.ActiveCfg = Debug|Any CPU', '.Deployment|Any CPU.ActiveCfg = Release|Any CPU') $sln = $sln.Replace('.Deployment|Any CPU.Build.0 = Debug|Any CPU', '.Deployment|Any CPU.Build.0 = Release|Any CPU') $sln = $sln.Replace('.Deployment|Mixed Platforms.ActiveCfg = Debug|Any CPU', '.Deployment|Mixed Platforms.ActiveCfg = Release|Any CPU') $sln = $sln.Replace('.Deployment|Mixed Platforms.Build.0 = Debug|Any CPU', '.Deployment|Mixed Platforms.Build.0 = Release|Any CPU') $sln = $sln.Replace('.Deployment|.NET.ActiveCfg = Debug|Any CPU', '.Deployment|.NET.ActiveCfg = Release|Any CPU') $sln = $sln.Replace('.Debug|.NET.ActiveCfg = Deployment|.NET', '.Debug|.NET.ActiveCfg = Development|.NET')   [System.IO.File]::WriteAllText($path, $sln) The script creates a backup of the solution file first, and then fixes up all the configs to use the correct builds. It's a simple search and replace list, so if there are any patterns that need to be added let me know and I'll update the script. A RegEx replace would be neater, but when it comes to hacking solution files, I prefer the conservative approach of knowing exactly what you're changing.

    Read the article

  • Replace Temp with Query

    - by student
    The Replace Temp with Query refactoring method is recommended quite widely now but seems to be very inefficient for very little gain. The method from the Martin Fowler's site gives the following example: Extract the expression into a method. Replace all references to the temp with the expression. The new method can then be used in other methods. double basePrice = _quantity * _itemPrice; if (basePrice > 1000) return basePrice * 0.95; else return basePrice * 0.98; becomes if (basePrice() > 1000) return basePrice() * 0.95; else return basePrice() * 0.98; double basePrice() { return _quantity * _itemPrice; } Why is this a good idea? surely it means the calculation is needlessly repeated and you have the overhead of calling a function. I know CPU cycles are cheap but throwing them away like this seems careless? Am I missing something?

    Read the article

  • [SOLVED] flash 10, as3 - save text of textarea and reuse it to replace text in textarea

    - by user427969
    hi everyone Is it possible to save text of textarea (flash 10, as3, cs5) in some variable or so and with its textformat (more than one color) and then reuse it to replace text in textarea? I tried saving htmlText of textarea but the problem is when i replace it in textarea tags causes problem. There will always be another extra line. If anyone wants to view p tags problem try following. Just click on text and then move your down arrow key, cursor will go to next line. import fl.controls.TextArea; var txtHTML:TextArea = new TextArea(); txtHTML.move(0,0); var default_format:TextFormat = new TextFormat(); default_format.font = "Arial"; default_format.bold = false; default_format.align = "center"; default_format.color = 0xFFFF00; default_format.size = 14; var field:TextField = txtHTML.textField; field.defaultTextFormat = default_format; field.setTextFormat(default_format); field.alwaysShowSelection = true; field.background = true; field.type = 'input'; field.multiline = true; field.backgroundColor = 0x777777; field.embedFonts = true; txtHTML.htmlText = '<P ALIGN="CENTER"><FONT FACE="_sans" SIZE="14" COLOR="#FFFF00" LETTERSPACING="0" KERNING="0">ASDF</FONT></P>'; field.x = 0; field.y = 0; field.width = 400; field.height = 200; field.text = ""; addChild(txtHTML); Is there a way to do this? Thanks alot for any help. Regards

    Read the article

  • How to replace a block of HTML with another block of HTML using jQuery

    - by tonsils
    Hi, Would appreciate some help with based on a condition, would like to replace the following html block: <table class="t12PageBody" cellpadding="0" cellspacing="0" width="100%" summary=""> <tr><td colspan="2">#REGION_POSITION_01#</td></tr> </table> <table width="100%" summary=""> <tr> <td class="t12ContentBody" valign="top"> #SUCCESS_MESSAGE# #NOTIFICATION_MESSAGE# #BOX_BODY# #REGION_POSITION_04##REGION_POSITION_05##REGION_POSITION_06##REGION_POSITION_07##REGION_POSITION_08#</td> <td align="right" valign="top" class="t12ContentBody">#REGION_POSITION_03#<br /></td> </tr> </table> with this block: <div id = "banner"> <div class="Logo"></div> <img src="http://www.abc.com/home/images/spacer.gif" height="35" width="180" border="0" alt=""> <font class="bannertext">&APPNAME.</font> <div class="bannerText"> <div class="hmenu"><ul>&APPLICATION_LINKS.</ul></div> </div> I looked at the replace function in query but unsure how to apply. Thanks.

    Read the article

  • Ubiquity CmdUtils.setSelection won't replace HTML

    - by Josh Timmer
    I'm attempting to write a Ubiquity command that allows you to replace a selected link or URL pointing to an image with that image itself. However, the CmdUtils.setSelection() function (documented here) seems to do nothing if any html tags are present in the selection, making it useless for replacing any links. When selecting plain text, it functions exactly as intended, replacing the text with an <img src="text"/> tag. Is there something I'm missing, or will this function simply not allow me to replace html? If the latter is the case, is there a function or method that will allow me to do this? Any other advice is welcome as well! CmdUtils.CreateCommand({ name: "fetch-image", author: {name: "Josh Timmer"}, license: "GPL", description: "Replaces links or URLs pointing to images with the image itself", help: "Highlight text or a hyperlink and execute this command", takes: {"image URL": /.*/}, _getImgUrl: function(itemIq) { if (itemIq.html.indexOf("<a ",0) < 0) return itemIq.text; var refPos = itemIq.html.indexOf("href=\"",0); if (refPos < 0) return "Error, no URL found!"; var startPos = itemIq.html.indexOf("\"", refPos); var endPos = itemIq.html.indexOf("\"", startPos + 1); startPos += 1; var url = itemIq.html.substring(startPos, endPos); return url; }, preview: function(pblock, input) { pblock.innerHTML = "Image URL: " + this._getImgUrl(input) + "<br/><br/><img src='" + this._getImgUrl(input) + "'/>"; }, execute: function img_insert(input) { CmdUtils.setSelection("<img src='" + this._getImgUrl(input) + "'/>"); displayMessage("Executed: " + this._getImgUrl(input)); } });

    Read the article

  • Using Regex Replace when looking for un-escaped characters

    - by Daniel Hollinrake
    I've got a requirement that is basically this. If I have a string of text such as "There once was an 'ugly' duckling but it could never have been \'Scarlett\' Johansen" then I'd like to match the quotes that haven't already been escaped. These would be the ones around 'ugly' not the ones around 'Scarlett'. I've spent quite a while on this using a little C# console app to test things and have come up with the following solution. private static void RegexFunAndGames() { string result; string sampleText = @"Mr. Grant and Ms. Kelly starred in the film \'To Catch A Thief' but not in 'Stardust' because they'd stopped acting by then"; string rePattern = @"\\'"; string replaceWith = "'"; Console.WriteLine(sampleText); Regex regEx = new Regex(rePattern); result = regEx.Replace(sampleText, replaceWith); result = result.Replace("'", @"\'"); Console.WriteLine(result); } Basically what I've done is a two step process find those characters that have already been escaped, undo that then do everything again. It sounds a bit clumsy and I feel that there could be a better way.

    Read the article

  • XSLT string replace

    - by aximili
    I don't really know XSL but I need to fix this code, I have reduced it to make it simpler. I am getting this error Invalid XSLT/XPath function on this line <xsl:variable name="text" select="replace($text,'a','b')"/> This is the XSL <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query" version='1.0'> <xsl:output method="text" encoding="UTF-8"/> <xsl:preserve-space elements="*"/> <xsl:template match="text()"></xsl:template> <xsl:template match="mos"> <xsl:apply-templates/> <xsl:for-each select="mosObj"> 'Notes or subject' <xsl:call-template name="rem-html"><xsl:with-param name="text" select="SBS_ABSTRACT"/></xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="rem-html"> <xsl:param name="text"/> <xsl:variable name="text" select="replace($text,'a','b')"/> </xsl:template> </xsl:stylesheet> Can anyone tell me what's wrong with it? Thanks in advance.

    Read the article

  • using XSL to replace XML nodes with new nodes

    - by iHeartGreek
    I need an XSL solution to replace XML nodes with new nodes. Say I have the following existing XML structure: <root> <criteria> <criterion>AAA</criterion> </criteria> </root> And I want to replace the one criterion node with: <criterion>BBB</criterion> <criterion>CCC</criterion> <criterion>DDD</criterion> So that the final XML result is: <root> <criteria> <criterion>BBB</criterion> <criterion>CCC</criterion> <criterion>DDD</criterion> </criteria> </root> I have tried using substring-before and substring-after to just copy the first half of the structure, then just copy the second half (in order to fill in my new nodes in between the two halves) but it appears that the substring functions only recognize text in between the nodes' tags, and not the tags themselves like I want them to. :( :( Any other solutions?

    Read the article

  • XSLT: need to replace document('')

    - by Daziplqa
    I've the following xslt file: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- USDomesticCountryList - USE UPPERCASE LETTERS ONLY --> <xsl:variable name="USDomesticCountryList"> <entry name="US"/> <entry name="UK"/> <entry name="EG"/> </xsl:variable> <!--// USDomesticCountryList --> <xsl:template name="IsUSDomesticCountry"> <xsl:param name="countryParam"/> <xsl:variable name="country" select="normalize-space($countryParam)"/> <xsl:value-of select="normalize-space(document('')//xsl:variable[@name='USDomesticCountryList']/entry[@name=$country]/@name)"/> </xsl:template> </xsl:stylesheet> I need to replace the "document('')" xpath function, what should I use instead? I've tried to remove it completely but the xsl document doesn't work for me! I need to to so because the problem is : I am using some XSLT document that uses the above file, say document a. So I have document a that includes the above file (document b). I am using doc a from java code, I am do Caching for doc a as a javax.xml.transform.Templates object to prevent multiple reads to the xsl file on every transformation request. I found that, the doc b is re-calling itself from the harddisk, I believe this is because of the document('') function above, so I wanna replace/remove it. Thanks.

    Read the article

  • Vim: yank and replace -- the same yanked input -- multiple times, and two other questions

    - by Hassan Syed
    Now that I am using vim for everything I type, rather then just for configuring servers, I wan't to sort out the following trivialities. I tried to formulate Google search queries but the results didn't address my questions :D. Question one: How do I yank and replace multiple times ? Once I have something in the yank history (if that is what its called) and then highlight and use the 'p' char in command mode the replaced text is put at the front of the yank history; therefore subsequent replace operations do not use the the text I intended. I imagine this to be a usefull feature under certain circumstances but I do not have a need for it in my workflow. Question two: How do I type text without causing the line to ripple forward ? I use hard-tab stops to allign my code in a certain way -- e.g., FunctionNameX ( lala * land ); FunctionNameProto ( ); When I figure out what needs to go into the second function, how do I insert it without move the text up ? Question three Is there a way of having a uniform yank history across gvim instances on the same machine ? I have 1 monitors. Just wondering, atm I am using highlight + mouse middle click.

    Read the article

  • Replace some column values depending on a condition, MATLAB

    - by darkcminor
    I have a matrix like A= 4.0000 120.0000 92.0000 0 0 37.6000 0.1910 30.0000 10.0000 168.0000 74.0000 0 0 38.0000 0.5370 34.0000 10.0000 139.0000 80.0000 0 0 27.1000 1.4410 57.0000 1.0000 139.0000 60.0000 23.0000 846.0000 30.1000 0.3980 59.0000 5.0000 136.0000 72.0000 19.0000 175.0000 25.8000 0.5870 51.0000 7.0000 121.0000 0 0 0 30.0000 0.4840 32.0000 I want to replace the values of the first column that are greater than '5' to 0, also in the second column if the values are in range 121-130 replace them by 0, if they are in range 131-140 replece by 1, 141-150 by 2, 151-160 by 3... so the result matrix would be A= 4.0000 0.0000 92.0000 0 0 37.6000 0.1910 30.0000 0.0000 4.0000 74.0000 0 0 38.0000 0.5370 34.0000 0.0000 1.0000 80.0000 0 0 27.1000 1.4410 57.0000 1.0000 1.0000 60.0000 23.0000 846.0000 30.1000 0.3980 59.0000 5.0000 1.0000 72.0000 19.0000 175.0000 25.8000 0.5870 51.0000 0.0000 0.0000 0 0 0 30.0000 0.4840 32.0000 How to acomplish this? I was trying something like counter=1; for i = 1: rows if A(i,1) > 5 A(i ,1) = 0; end if A(i,2) > 120 && A(i,2) < 130 A(i ,2) = 0; end counter = counter+1; end Using a case could do the trick?

    Read the article

  • MS SQL find and replace in TEXT field

    - by incubushead
    I have a database in MS SQL 2005 that was brought up from SQL 2000 and is still using TEXT type fields instead of varchar(max). I need to find and replace a string of characters in the text field but all of the examples of how to do this that I have found don't seem like they would work for me. It seems the UPDATETEXT command requires that the two parameters "insert_offset" and "delete_length" be set explicitly but the string i am searching for could show up in the text at any point or even at several points in the same cell. My understanding of these two parameters is that the string im searching for will always be in the same place, so that insert_offset is the number of spaces into the text that the UPDATETEXT command will start replacing text. Example: Need to find: &lt;u&gt; and Replace it with: <u> Text field example: *Everyone in the room was <b>&lt;u&gt;tired&lt;/u&gt;.</b><br>Then they woke <b>&lt;u&gt;up&lt;/u&gt;. Can anyone help me out with this? THANKS!

    Read the article

  • updating multiple nodes in xml with xquery and xdmp:node-replace

    - by morja
    Hi all, I wnat to update an XML document in my xml database (Marklogic). I have xml as input and want to replace each node that exists in the target xml. If a node does not exist it would be great if it gets added, but thats maybe another task. My XML in the database: <user> <username>username</username> <firstname>firstname</firstname> <lastname>lastname</lastname> <email>[email protected]</email> <comment>comment</comment> </user> The value of $user_xml: <user> <firstname>new firstname</firstname> <lastname>new lastname</lastname> </user> My function so far: declare function update-user ( $username as xs:string, $user_xml as node()) as empty-sequence() { let $uri := user-uri($username) return for $node in $user_xml/user return xdmp:node-replace(fn:doc($uri)/user/fn:node-name($node), $node) }; First of all I cannot iterate over $user_xml/user. If I try to iterate over $user_xml I get "arg1 is not of type node()" exception. But maybe its the wrong approach anyway? Does anybody maybe have sample code how to do this?

    Read the article

  • XSLT: replace an integer by a string

    - by binogure
    I have a little problem. A node in my XML may contains and integer, and i have to replace this integer by a string. Each number match with a string. For example i have: Integer - String 1 - TODO 2 - IN PROGRESS 3 - DONE 4 - ERROR 5 - ABORTED Original XML: <root> <status>1</status> </root> Converted XML: <root> <status>TODO</status> </root> So i want replace 1 by "TODO", 2 by "IN PROGRESS" ... <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/root/status"> <root> <status> <xsl:variable name="text" select="." /> <xsl:choose> <xsl:when test="contains($text, '1')"> <xsl:value-of select="'TODO'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </status></root> </xsl:template> </xsl:stylesheet> I'am asking if there is another way to do that.

    Read the article

  • using Jquery, replace html elements with own values

    - by loviji
    Hello, I have a table, has many rows. for example one of from rows(all rows are same): <tr> <td> <input type="text" /> </td> <td> <textarea cols="40" rows="3" ></textarea> </td> <td> <select> //options </select> </td> <td> <input type="text" /> </td> <td> <input type="checkbox" /> </td> </tr> Rows can be dynamically added by jquery after button click. I'm trying to do: after button click add new row(I do it) and replace previous row Html Elements(input type=text, textarea, select, input type=text, /[input type="checkbox" must be safe]) with its own values. And after if i click on row(anyrow), i want to rollback previous operation. i.e. replace texts with html element. and htmlElement.val()=text. Added after 30 minutes: I wrote for input type=text element and textarea element this. $("#btnAdd").click(function() { $input = $('#mainTable tbody>tr:last').closest("tr").find("td > input:text"); $input.replaceWith($input.val()); $textArea = $('#mainTable tbody>tr:last').closest("tr").find("td > textarea"); $textArea.replaceWith($textArea.val()); }); is this a good idea?

    Read the article

  • jQuery way to replace just a text node with a mix of HTML and text

    - by hippietrail
    In my web browser userscript project I need to replace just one text node without affecting the other HTML elements under the same parent node as the text. And I need to replace it with more than one node: <div id="target"> some text<img src="/image.png"> </div> Needs to become: <div id="target"> <a href="#">mixed</a> text <a href="#">and</a> HTML<img src="/image.png"> </div> I know jQuery doesn't have a whole lot of support for text nodes. I know I could use direct DOM calls instead of jQuery. And I know I could just do something like $('#target').html(my new stuff + stuff I don't want to change). What I'd like to ask the experts here is, Is there a most idiomatic jQuery way to do this?

    Read the article

  • SQL Server find and replace in TEXT field

    - by incubushead
    I have a database in SQL Server 2005 that was brought up from SQL Server 2000 and is still using TEXT type fields instead of varchar(max). I need to find and replace a string of characters in the text field but all of the examples of how to do this that I have found don't seem like they would work for me. It seems the UPDATETEXT command requires that the two parameters "insert_offset" and "delete_length" be set explicitly but the string i am searching for could show up in the text at any point or even at several points in the same cell. My understanding of these two parameters is that the string im searching for will always be in the same place, so that insert_offset is the number of spaces into the text that the UPDATETEXT command will start replacing text. Example: Need to find: &lt;u&gt; and Replace it with: <u> Text field example: *Everyone in the room was <b>&lt;u&gt;tired&lt;/u&gt;.</b><br>Then they woke <b>&lt;u&gt;up&lt;/u&gt;. Can anyone help me out with this? THANKS!

    Read the article

  • PHP text formating: Detecting several symbols in a row

    - by ilnur777
    I have a kind of strange thing that I really nead for my text formating. Don't ask me please why I did this strange thing! ;-) So, my PHP script replaces all line foldings "\n" with one of the speacial symbol like "|". When I insert text data to database, the PHP script replaces all line foldings with the symbol "|" and when the script reads text data from the database, it replaces all special symbols "|" with line folding "\n". I want to restrict text format in the way that it will cut line foldings if there are more than 2 line foldings used in each separating texts. Here is the example of the text I want the script to format: this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... I want to restict format like: this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... So, at the first example there is only one line folding between 2 texts and on the second example there are 3 line foldings between 2 texts. How it can be possible to replace more than 2 line foldings symbols "|" if they are detected on the text? This is a kind of example I want the script to do: $text = str_replace("|||", "||", $text); $text = str_replace("||||", "||", $text); $text = str_replace("|||||", "||", $text); $text = str_replace("||||||", "||", $text); $text = str_replace("|||||||", "||", $text); ... $text = str_replace("||||||||||", "||", $text); $text = str_replace("|", "<br>", $text); HM, I HAVE PROBLEMS! THIS DOES NOT WORK WHEN TEXT DATA IS SENT IN POST METHOD. LOOK AT THIS: //REPLACING ALL LINE FOLDINGS WITH SPECIAL SYMBOL $_POST["text"] = str_replace("\n","|",$_POST["text"]); // REMOVING ALL LINE FOLDINGS $_POST["text"] = trim($_POST["text"]); // IF THERE ARE MORE THAN 3 LINE HOLDINGS - FORMAT TO 1 LINE HOLDING $_POST["text"] = preg_replace("/\|{3,}/", "||", $_POST["text"]); echo $_POST["text"];

    Read the article

  • PHP text formating: Detectng several symbols in a row

    - by ilnur777
    I have a kind of strange thing that I really nead for my text formating. Don't ask me please why I did this strange thing! ;-) So, my PHP script replaces all line foldings "\n" with one of the speacial symbol like "|". When I insert text data to database, the PHP script replaces all line foldings with the symbol "|" and when the script reads text data from the database, it replaces all special symbols "|" with line folding "\n". I want to restrict text format in the way that it will cut line foldings if there are more than 2 line foldings used in each separating texts. Here is the example of the text I want the script to format: this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... I want to restict format like: this is text... this is text... this is text...this is text...this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... this is text... So, at the first example there is only one line folding between 2 texts and on the second example there are 3 line foldings between 2 texts. How it can be possible to replace more than 2 line foldings symbols "|" if they are detected on the text? This is a kind of example I want the script to do: $text = str_replace("|||", "||", $text); $text = str_replace("||||", "||", $text); $text = str_replace("|||||", "||", $text); $text = str_replace("||||||", "||", $text); $text = str_replace("|||||||", "||", $text); ... $text = str_replace("||||||||||", "||", $text); $text = str_replace("|", "<br>", $text);

    Read the article

  • Why is str_replace not replacing this string?

    - by Niall
    I have the following PHP code which should load the data from a CSS file into a variable, search for the old body background colour, replace it with the colour from a submitted form, resave the CSS file and finally update the colour in the database. The problem is, str_replace does not appear to be replacing anything. Here is my PHP code (stored in "processors/save_program_settings.php"): <?php require("../security.php"); $institution_name = mysql_real_escape_string($_POST['institution_name']); $staff_role_title = mysql_real_escape_string($_POST['staff_role_title']); $program_location = mysql_real_escape_string($_POST['program_location']); $background_colour = mysql_real_escape_string($_POST['background_colour']); $bar_border_colour = mysql_real_escape_string($_POST['bar_border_colour']); $title_colour = mysql_real_escape_string($_POST['title_colour']); $url = $global_variables['program_location']; $data_background = mysql_query("SELECT * FROM sents_global_variables WHERE name='background_colour'") or die(mysql_error()); $background_output = mysql_fetch_array($data_background); $css = file_get_contents($url.'/default.css'); $str = "body { background-color: #".$background_output['data']."; }"; $str2 = "body { background-color: #".$background_colour."; }"; $css2 = str_replace($str, $str2, $css); unlink('../default.css'); file_put_contents('../default.css', $css2); mysql_query("UPDATE sents_global_variables SET data='{$institution_name}' WHERE name='institution_name'") or die(mysql_error()); mysql_query("UPDATE sents_global_variables SET data='{$staff_role_title}' WHERE name='role_title'") or die(mysql_error()); mysql_query("UPDATE sents_global_variables SET data='{$program_location}' WHERE name='program_location'") or die(mysql_error()); mysql_query("UPDATE sents_global_variables SET data='{$background_colour}' WHERE name='background_colour'") or die(mysql_error()); mysql_query("UPDATE sents_global_variables SET data='{$bar_border_colour}' WHERE name='bar_border_colour'") or die(mysql_error()); mysql_query("UPDATE sents_global_variables SET data='{$title_colour}' WHERE name='title_colour'") or die(mysql_error()); header('Location: '.$url.'/pages/start.php?message=program_settings_saved'); ?> Here is my CSS (stored in "default.css"): @charset "utf-8"; /* CSS Document */ body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #000; } body { background-color: #CCCCFF; } .main_table th { background:#003399; font-size:24px; color:#FFFFFF; } .main_table { background:#FFF; border:#003399 solid 1px; } .subtitle { font-size:20px; } input#login_username, input#login_password { height:30px; width:300px; font-size:24px; } input#login_submit { height:30px; width:150px; font-size:16px; } .timetable_cell_lesson { width:100px; font-size:10px; } .timetable_cell_tutorial_a, .timetable_cell_tutorial_b, .timetable_cell_break, .timetable_cell_lunch { width:100px; background:#999; font-size:10px; } I've run some checks using the following code in the PHP file: echo $css . "<br><br>" . $str . "<br><br>" . $str2 . "<br><br>" . $css2; exit; And it outputs (as you can see it's not changing anything in the CSS): @charset "utf-8"; /* CSS Document */ body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #000; } body { background-color: #CCCCFF; } .main_table th { background:#003399; font-size:24px; color:#FFFFFF; } .main_table { background:#FFF; border:#003399 solid 1px; } .subtitle { font-size:20px; } input#login_username, input#login_password { height:30px; width:300px; font-size:24px; } input#login_submit { height:30px; width:150px; font-size:16px; } .timetable_cell_lesson { width:100px; font-size:10px; } .timetable_cell_tutorial_a, .timetable_cell_tutorial_b, .timetable_cell_break, .timetable_cell_lunch { width:100px; background:#999; font-size:10px; } body { background-color: #CCCCFF; } body { background-color: #FF5719; } @charset "utf-8"; /* CSS Document */ body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #000; } body { background-color: #CCCCFF; } .main_table th { background:#003399; font-size:24px; color:#FFFFFF; } .main_table { background:#FFF; border:#003399 solid 1px; } .subtitle { font-size:20px; } input#login_username, input#login_password { height:30px; width:300px; font-size:24px; } input#login_submit { height:30px; width:150px; font-size:16px; } .timetable_cell_lesson { width:100px; font-size:10px; } .timetable_cell_tutorial_a, .timetable_cell_tutorial_b, .timetable_cell_break, .timetable_cell_lunch { width:100px; background:#999; font-size:10px; }

    Read the article

  • How to programmatically replace UIToolBar items built in IB

    - by frankodwyer
    I have a toolbar with various image buttons, created in Interface Builder. I'd like to be able to programmatically replace one of the buttons with an activity indicator when pressed, and then put back the original button but change its color from white to yellow when the activity completes. Is this possible with an IB built toolbar or must I look at building the whole toolbar programmatically and custom views?

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >