- How do you refer to an HTML carriage return in PHP?

Someone sent me a php script that replaces foul language with
kinder words
in message board postings. I'd like the same script to weed
out carriage
returns, but we can't find the correct syntax for it.
We're using :
$patterns[0] = '/\n\r/';
What's the correct syntax to use in this situation?
Thanks!

"David Powers" <[email protected]> wrote in message
news:[email protected]...
> Reese wrote:
>> "David Powers" <[email protected]> wrote in
message
>>>
>>>$patterns[0] = '/[\n\r]/';
>>>
>>>That searches for either a newline character or a
carriage return.
>>
>> I'm told this will only work in Windows. That Macs
would require a
>> different string. Two, even.
>>
>> Anyone know if this is true?
>
> What you have been told is only partly correct. Windows
uses a carriage
> return followed by a newline character (\r\n). Macs just
use a newline
> character (\n).
>
> The pattern I have given you search for either a newline
character or
> carriage return. So if it's applied in such a way as to
remove all
> instances, it will work on both Windows and Mac. An
alternative pattern
> which would also work on both is this:
>
> $patterns[0] = '/\r?\n/';
>
> It looks for an optional carriage return followed by a
newline character.
> In other words, it still matches if there isn't a
carriage return.
The response of my know-it-all roumanian programmer with an
ego the size of
Texas to that was :
http://www.regular-expressions.info/characters.html
(bottom of the page)
\r\n = windows
\n = Linux (not Mac)
\r = Mac
http://www.regular-expressions.info/optional.html
(tells you what the '?'
does)
(it means that the character before it can be there 0 or 1
times)
\r?\n = \n (Linux) or \r\n (windows)
It leaves out the \r all alone, like added by the Mac.
So, it will not delete the Mac new lines (might delete the
Mac OSX ones
since that one is passed on Linux, but not the older ones.)
Now, you can contradict me all you want and have a busted
code (then you
will say it doesn't work because I made it wrong), or do it
like I told you
and get it working like it should.
To this, I told him I would present this to you for a
rebuttal, but not
before asking him why he used only the '/\r?\n/' model as an
example, and
not the recommended '/[\n\r]/'. Something tells me he has no
idea what [
and ] do in this context, so he's avoiding it altogether --
even though it
may very well solve the problem on its own the way you claim
it does.

Similar Messages

  • How to you refer to a function in another function in a cfc

    HI,
    How to you refer to a function in another function in a cfc like so
    <cffunction name="getApplicationConstants" access="remote" returntype="struct">
             <cfset flash.result.users = [the result from the getUsers function]>
        <cfreturn flash.result>
    </cffunction>
    <cffunction name="getUsers" access="remote" returntype="query">
            <cfquery name="q" datasource="#datasource#">
                select     c.*
                from    USERS as c    WHERE looksLikeUserIsDeleted = 'False'
                AND userPrivileges = 1
                ORDER BY fullName
            </cfquery>
            <cfset flash.result = q>
            <cfreturn flash.result>
    </cffunction>

    Hi, Nikos,
    If the CFCs are in the same directory, you could do the following:
    CFCA
    <cfcomponent>
    <cffunction name="getApplicationConstants" access="remote" returntype="struct">
        <cfset flash.result.users = cfcB.getUsers() />
        <cfreturn flash.result>
    </cffunction>
    </cfcomponent> 
    CFCB
    <cfcomponent>
    <cffunction name="getUsers" access="remote" returntype="query">   
            <cfquery name="q" datasource="#datasource#">
                select     c.*
                from    USERS as c    WHERE looksLikeUserIsDeleted = 'False'
                AND userPrivileges = 1
                ORDER BY fullName       
            </cfquery>
            <cfset flash.result = q>
            <cfreturn flash.result>
    </cffunction>
    <cfcomponent>
    If the CFCs were in different directories, the cfset expression in CFCA would be this:
    <cfset flash.result.users = path.to.cfc.cfcB.getUsers() />
    Where I have path.to.cfc, you would use either a mapping from CF Admin or the hierarchy of folders to the CFC from the web root.
    Does that help?

  • How do you limit the number of rows return from query?

    How do you limit the number of rows return from query? Do all databases support this kind of feature?

    i think the standard is limit
    to get the top 30
    select * from mytable LIMIT 30;returns the first 30 rows
    also if you want a range
    select * from mytable LIMIT 10,30;returns 30 rows starting from 10
    this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages

  • How do i add a newline or carriage return to make my xml file look pretty?

    Hi guys
    I'm writing an xml file with jsp, the problem is, it writes it in one big chunk of text. e.g.
    <start>hello, my name is joe</start><middle>I like trees</middle><end>boo</end>
    Now what I want to do is present this xml file in a decent manner,
    e.g.
    <start>hello my name is joe</start>
    <middle>i like trees</middle>
    <end>boo</end>
    i've tried
    xmlFile = "<start>Hello my name is joe</start>"+\n\r;
    and
    xmlFile ="<start>Hello my name is joe</start>"+"\n\r";
    neither work, can anyone provide me with some insight into how I can add a carriage return / new line to make my xml file look pretty?
    Many thanks for any responses!

    u r right <BR> tag will not work...
    I wrote following code to generate xml file and it works fine...U can try the same...
    try
    FileOutputStream fos = new FileOutputStream("c:\\temp.xml");
    String xmlString = "<root>\n<start>Hello my name is joe</start>"+"\n";
    xmlString = xmlString +"<middle>blah blah</middle>\n</root>";
    fos.write(xmlString.getBytes());
    fos.close();
    fos = null;
    catch(Exception e)
    e.printStackTrace();
    }

  • HT5176 How do you go to "next line" or RETURN key in dictation on an iPad3?

    Using dictation on an iPad3 - how do you go to a new line (same as hitting the return key)?

    When using dictation I can't get "New Line" to work. It simply types this phrase! The "New Paragraph" command works, but adds all these additional spaces into my text. Has anybody got ideas on how to resolve? Is there another way to dictate a "return key"?

  • Hold carriage returns in PHP MySQL database?

    I'm creating a limited news database for a not-for-profit
    site and I want to let admin users write a long entry which may
    include multiple paragraphs (i.e. carriage returns) and even bold
    text for subheadings would be nice. I haven't been able to find out
    the proper code and DB settings to allow users to do this.
    Anyone have a simple solution?

    The way I handle text formatting with dynamic data is to
    carefully construct
    your DB with formatting in mind
    Create separate fields for headlines and copy. When you call
    the data to
    your web page surround the heading with the desired tag. Of
    course you will
    not always have a heading, so, to eliminate empty spaces add
    a conditional
    statement to ignore the field if it is null.
    like this:
    database:
    news_id
    news_headline1
    news_copy1
    news_headline2
    news_copy2
    web page:
    <?php if (strlen($row_getNews['news_headline1']) > 0)
    {?>
    <h3><?php echo $row_getNews['news_headline1'];
    ?></h3>
    <?php }?>
    <p><?php echo $row_getNews['news_copy1'];
    ?></p>
    <?php if (strlen($row_getNews['news_headline2']) > 0)
    {?>
    <h3><?php echo $row_getNews['news_headline2];
    ?></h3>
    <?php }?>
    <?php if (strlen($row_getNews['news_copy2']) > 0)
    {?>
    <p><?php echo $row_getNews['news_copy2'];
    ?></p>
    <?php }?>
    Jeff
    "Justin from Indiana" <[email protected]>
    wrote in message
    news:fiimo4$33$[email protected]..
    > I'm creating a limited news database for a
    not-for-profit site and I want
    > to
    > let admin users write a long entry which may include
    multiple paragraphs
    > (i.e.
    > carriage returns) and even bold text for subheadings
    would be nice. I
    > haven't
    > been able to find out the proper code and DB settings to
    allow users to do
    > this.
    >
    > Anyone have a simple solution?
    >

  • How do you convert projects from html 5 to ac3?

    I started a project using html 5 but i want to switch it to an action script 3.0 project. I know its really easy to switch ac3 to html 5, but i cant find the other way around.

    This forum is actually about the Cloud, not about using individual programs
    Once your program downloads and installs with no errors, you need the program forum
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

  • How do you connect Flash Builder to a NON-LOCAL PHP Server?

    Is it possible to connect Flash Builder 4 to a non-local PHP Server?  In my case, I want to connect to a PHP server on my web-host (similar to GoDaddy).
    This seems like a really stupid question, but every single tutorial or forum post I've Googled in the past 2 hours talk about how easy this is but all of them use "...localhost..." in the Root URL and I can't find anywhere in Flash Builder to enter FTP style credientals!
    I do not want to turn my PC into a PHP/SQL/IIS server.  I want to be able to do all of my work remotely as I do with Dreamweaver. 
    I've been trying to do this one simple thing for the better part of 2 days and can't believe how under-documented this feature is.
    Please please please help!
    Thanks
    Charles

    Upload your services to a directory on your host, upload your remoting app (Zend AMF etc) and configure it, then change the end point in your code to the gateway.php on your server:
    yourService.endpoint = "http://www.yoururl.com/pathway-to-your/gateway.php";
    For instance, one of mine are:
    protected function updateButton_Click(event:MouseEvent):void
                    // TODO Auto-generated method stub
                    support_Requests.ticket_id = supportGrid.selectedItem.ticket_id;
                    support_Requests.hub = supportGrid.selectedItem.hub;
                    support_Requests.username = supportGrid.selectedItem.username;
                    support_Requests.contactNumber = supportGrid.selectedItem.contactNumber;
                    support_Requests.email = supportGrid.selectedItem.email;
                    support_Requests.request = supportGrid.selectedItem.request;
                    support_Requests.status = statusButtons.selectedValue.toString();
                    support_Requests.note = noteUpdate.text;
                    supportRequestsService.endpoint = "http://www.not-telling-you-my-url/app-resources/gateway.php";
                    updateSupport_RequestsResult.token = supportRequestsService.updateSupport_Requests(support_Requests);
                    currentState='Home';

  • How do you change the number of rows returned by an advanced datagrid...Only displays 1000 rows....I

    I am using coldfusion to query an oracle table....Query returns approximately 2000 rows, however the max rows the datagrid will display is 1000.  Does anybody know how to change this...THANKS!!

    Thanks so much for your answer that sounds like a good idea...
    I found the answer to my initial problem...In my coldfusion I had set maxrows = 1000.  So the datagrid was always returning 1000 records even when a lot more than that should have been returned...When I removed the maxrows parameter in the coldfusion code, my datagrid was now been populated with the correct number of rows...
    thanks again for your help,
    Ronnie Raigrodski (Aka -- FlexNerd)

  • How do you "push" into an array and return array without commas?

    Hi.  In AS 3.0 I have declared an Array as a new Array();
    I would like to push objects into that array but have a text field read back the array minus the commas that are pushed by user interaction (from numbered buttons).
    For example, if the user pushes button 1 then button 4 then button 8 I would like the array to read in the text field 148 instead of 1,4,8 .
    This seems easy but I looked at the AS 3 reference and couldn't determine whether pop() would do it.

    Does the following help in any way?
    var vb:Array = new Array(1,2,3);
    trace(vb);
    trace(vb.join(""));

  • How can you link up online files to a offline file

    I have asked this question before, but did not get the answer I needed. So I though for a bit and came up with a more understand able question and how to explain it and here it is:
    What I want to know, is how can you link an online html link to an offline swf file? Now this is needed because people need to download the swf file in order to use it, I have tried this:     file://swf/Lr1.swf (link), but it doesn't work it comes up with not found. So can any one help?

    drunkmafia wrote:
    I have asked this question before, but did not get the answer I needed. So I though for a bit and came up with a more understand able question and how to explain it and here it is:
    What I want to know, is how can you link an online html link to an offline swf file? Now this is needed because people need to download the swf file in order to use it, I have tried this:     file://swf/Lr1.swf (link), but it doesn't work it comes up with not found. So can any one help?
    Personally I think you are going about this all wrong.  I believe someone recommended to you in a previous post to look into the HTML5  ( http://forums.adobe.com/thread/874917 ) you need to end up creating the site with Adobe AIR as opposed to the way you are going about doing it.  That would be creating an application like Tweetdeck that connects to the internet and uses interactive elements.  http://www.adobe.com/devnet/air.html
    If you want to link a file within a Flash document you would receive a quicker and more in depth answer in the Flash forum as it will require ActionScript.
    http://forums.adobe.com/community/flash
    It sounds like you have a ton of ideas, but your lack of information suggests that 1. you don't have all the knowledge necessary to get the project off the ground and 2. your reluctance to share it suggests that you have an idea that you feel the program is proprietary.  Given that this is the case you might be best served looking for an experienced Flash or AIR developer to help get your ideas going in motion. There is nothing wrong with trying to learn but the information you are giving up to go on is very broad and unfortunately it does not appear that you are getting the answers you are looking for.

  • Invalid column name - fixed by inserting a carriage return - Why?

    I'm writing some JSP pages and am executing a statement that retrieves values from three tables.
    When executing the statement I receive the error
    java.sql.SQLException: Invalid column name
    I just want to state here that ALL the column names are definitely correct. I attempted to isolate the problem using my SQL*Plus Interface.
    When copying and pasting the SQL that was used (I put the SQL statement into the HTML to allow me to do this) into SQL*Plus it also come up with the error. I found that if I broke up the statement it would run. Specifically if I placed a carriage return (by hitting enter) prior to the 'A' of the AND operator and then copied and pasted into SQL*Plus it would work!
    I thought the problem was related to bad syntax in the outer join operator. But removal of the outer join operator and making it a EQUI JOIN situation still gave the same results. I tried the use of brackets to 'help' the DB engine figure it out - silly I know, but it didn't work anyway :(
    I've tried this out on UNIX in SQL*Plus where the query was on one line and it worked fine. I've tried it on Oracle 8.1.5 SQL*Plus & Oracle 8.1.7 SQL*Plus on Win2000 and WinNT and no go.
    It has also been tested on an Oracle 7.3.4 DB and no go either.
    Remember I'm only using SQL*Plus to find out why it is not working - I'm actually attempting to execute this via JDBC (classes12.zip Oracle9 version) in my JavaBean. I can't place a carriage return to 'fix' the problem, and I'm assuming that I shouldn't either.
    I've pasted the SQL below (both non-working and working versions). I was going to paste the output of DESC on the associated tables should you too would rule out a mispelled column name, but I didn't want to put anyone off with a long post.
    If you can provide any advice I would be very appreciative.
    Darren James
    Show Me Technology
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS
    .Novell_User_Name = PERSON.Novell_User_Name (+) ORDER BY Make,
    Model, Asset_Number,Serial_Number,
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_Name;
    3 /
    WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS.Novel
    ERROR at line 2:
    ORA-00904: invalid column name
    REM -- Using the one with an return prior to the AND
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+)
    3 AND UNIT_USERS.Novell_User_Name = PERSON.Novell_User_Name
    (+) ORDER BY Make, Model,
    4 Asset_Number,Serial_Number,
    5
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_
    Name;
    ASSET_NUMBER
    MODEL
    NOVELL_USE
    10023445
    desktop raider
    tabisho
    10023445
    desktop raider
    pjblee
    100349864
    VEi8
    SQL>

    Ok. I feel ashamed that the answer was so simple and not the
    problem I thought it was. But in the interests of perhaps
    preventing someone else doing the same silly thing....
    The error was caused by using a wrong name when 'getting' the
    values int the return ResultSet object. (eg using getString
    ("s.Some_Name") when it should have been getString
    ("s.Another_Name").
    Interestingly the error did occur in one of our SQL*Plus
    versions. Why we still are not sure, but since this was a silly
    error on my part, I'm sure a similarly silly reason will be the
    cause there two.
    I appreciate those who responded though. It is a great resource.
    Darren James
    I'm just guessing here, but could it be some sort of a size thing? Could it be that, if you don't break up line 2, somehow
    it gets truncated or wrapped at an inappropriate place? To test
    this theory, you might try putting the carriage return in front
    of the ORDER BY, instead of in front of the AND, and see if it
    has the same effect. If you do get it figured out, please
    satisfy our curiosity and let us know.

  • Carriage returns in OAException message

    Hi,
    I am creating an OAException message based on a String;
    String exceptionMessage = "";
                if (pageContext.getParameter("OrgId").isEmpty()) {
                    exceptionMessage = "Please select a valid Organisation";
                if (pageContext.getParameter("BankAccountNum").isEmpty()) {
                    exceptionMessage =
                            exceptionMessage + "\nPlease select a valid Bank Account";
    throw new OAException(exceptionMessage, OAException.ERROR);
    Is it possible to have carriage returns in an exception message? I have added /n within the String, however it is not showing a carriage return when running it?
    Kind Regards
    Carl

    If you are using message dictionary you can put carriage returns easily.(Whenever you are raising any error message, as per standards you should use message dictionary. You can change the message text without touching the java code).
    Here are the steps
    1) Create a message named XXX_YOUR_MESSAGE using Application Developer responsibility with your custom message. Make sure you set the application(as per below example I am using Human Resources) of the message properly as it needs to be referred in your java code
    2) Just write below code where ever you want.
                OAException myOAException = new OAException("PER", "XXX_YOUR_MESSAGE", null, OAException.ERROR, null); //You can even use OAException.ERROR or OAException.WARNING etc. Just explore the class OAException for further options.
                throw myOAException;
    So as per the message you set, it will display carriage returns. You can even use HTML tags I guess but I never tried.
    If you want to set tokens in your message you can use below code
           MessageToken[] arrayOfMessageToken = new MessageToken[] { new MessageToken("MY_TOKEN", "My Token Text") };
           OAException myOAException = new OAException("PER", "XXX_YOUR_MESSAGE", arrayOfMessageToken, OAException.ERROR, null);
           throw myOAException;
    Regards,
    Peddi.

  • JSP for Vcard cannot strip carriage return in the last line of the file.

    I am using JSP to output a Vcard (http://en.wikipedia.org/wiki/VCard)
    The following code works great in Windows but fails on the mac:
    <%@ page contentType="text/x-vcard" %><%--
    --%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--
    --%><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%--
    --%>BEGIN:VCARD
    VERSION:2.1
    <c:choose><%--
    --%><c:when test="${not ((empty param.lan) and (empty param.fin)) }"><%--
    --%>N:${param.lan};${param.fin}
    FN:${param.fin} ${param.lan}
    </c:when><%--
    --%><c:otherwise><%--
    --%>FN:${param.org}
    </c:otherwise><%--
    --%></c:choose><%--
    --%>ORG:${param.org}
    TITLE:${param.title}
    TEL;WORK;VOICE:${param.phwork}
    ADR;WORK:;;${param.st};${param.city};${param.state};${param.zip};
    EMAIL;PREF;INTERNET:${param.email}
    REV:20080424T195243Z
    <c:out value="${fn:replace('END:VCARD','\\\r','')}" escapeXml="false"/>After some tests, I discovered that Mac (I used Tiger, latest update, not Leopard) needs extra white space and carriage returns stripped off. Once this is achieved, the vcard will automatically import into Address Book. I have followed other forums which advice on using JSP comments as in the code above. But for some strange reason the last line of the JSP outputs an extra carraige return. How do I get rid of the carriage return at the end of the file? the replace function from JSTL is not working.
    Edited by: shogo2040 on Dec 18, 2008 7:11 PM : I added more detail to the Subject

    I originally had that END:VCARD without any carriage return.
    But I still get an extra carriage return at the end when the JSP renders to VCF
    I'm using Tomcat running on Linux.
    I found this, article which implies (but does not explicitly say) JSP in general adds a newline to the last line:
    http://www.caucho.com/resin-3.0/jsp/faq.xtp (But its not tomcat either, so maybe this info is irrelevant).
    Edited by: shogo2040 on Dec 22, 2008 3:31 PM - changed rendered to VCF from rendered to JSP

  • How to replace an html br tag in the field to a carriage return?

    Hi All,
    I have a requirement to replace the <<br>> tag in the text field with a carriage return character "
    Currently the data in the Comments field looks like :
    "20100627 -115541 SECURITY WILL MEET AT MAIN ENTERANCE"<<<br>>"20100627 -115605 Officer notified: ALPHA : DF-10-011891; ST VINCENTS HOSPITAL, ST VINCENTS HOSPITAL, SAINT VINCENTS HOSP, MERRION RD, MERRION, BOOTERSTOWN, DUBLIN; FIRE/ALARM ACTIVATION;'<<br>>'20100627 -115609 PDA MOBILISED AFTER AMENDMENT VIN1'<<br>>'20100627 -"
    The <<br>> break tag was used for HTML purpose and now I would like to replace it with a carriage return character for BI Publisher report.
    Appreciate3 your help.
    Regards
    B
    Edited by: Bees on Jul 21, 2010 4:36 AM

    I downloaded your html template and it works fine for that template and the xml, but in my case it is not working. I need to assign the template just for one field called "Comments" where I need <<br>> tag to work.
    I modified the html as you suggested with the Tidy software, here is what I have done may be you can help me here. I very much appreciate your help.
    1. I have imported the template with the tag <<?import:file:///C:/dfb/biPub/code/htmlmarkup.xsl?>> and it works fine.
    2. Assigned the xsl - assign-template to the comments field.
    <xsl:apply-templates select="Fact._COMMENTS_" />
    *** IncidentsFact_._COMMENTS is the field name where it has <<br>><</br>> embedded into the comments data.
    Edited by: Bees on Jul 30, 2010 6:29 AM

Maybe you are looking for

  • How do I delete songs from the iPhone??

    hey guys, I read that in order to delete songs from the iPhone you need to remove the songs from iTunes then re-sync it. I did that but the songs are still in the iPhone and are no longer on iTunes. Songs are all greyed out in iPhone. Please help, th

  • IMac G5 Freezes

    About three weeks ago, our iMac G5 froze. Then it froze more or less every day. Then it went a week or so without freezing, then started again last week. We had an expansion memory module 512M installed, so I pulled it. Computer seemed ok for the res

  • How can I get iphoto theme to start making a book?

    I have made iphoto books for printing before on my iMac but now I cannot.  The computer says there are no themes loaded.  Any ideas on how to fix this?

  • Lost iBook project

    I made, and purchased an iBook. It arrived, but does not show up in my Projects Bookshelf. Where is it and how do I store it with my other projects?

  • The installation Failed = All dmgs that reququire password prompt

    Hi, I have a strange issue on my mac whereby all dmg installers fail to install at the 'installation' stage whenever it prompts for a password during installation. For other applications where the installer does not prompt for a password, it installs