Trimming a string using spaces as a delimitter

I'm trying to retreive email addresses from individual message bodies. I'm using the following code and it is working well :
<cfset addrpos = ListContainsNoCase(getmail.body, "@", " <> ")>
     <cfif addrpos neq 0>
     <cfset email = ListGetAt(getmail.body, addrpos, " <> ")>
     </cfif>
For the most part this is working well, but at times the <> characters  are not surrounding the email address in the message bodyand I'm ending up with the email address and a combination of the word before, word after or both. Is there a better way to handle this situation? I tried the following which works when I set the email variable in the example, but does not work when I use the same code in the loop that is getting the original email variable.
<cfset email = "adfga: [email protected] adfw asdfa">
<cfset addrpos1 = ListContainsNoCase(email, "@", " ")>
<cfset EMAIL = ListGetAt(email, addrpos1, " ")>
I looked at the GetToken function but did not think that it would be a better way to go at it. Any other ideas?

Finding email addresses in a bunch of text without using regular expressions? Mad, I say, Mad!
Hints:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7e 9a.html
Try using regular expression to match any valid email:
[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}
Allow returnsubexpressions on ReFind to return multiple hits on the message body.
Use cfdump to check how you must access the result array.
Hope this helps.
- Fernis - fernis.net - ColdFusion Developer For Hire

Similar Messages

  • Use REGEXP_INSTR to find a text string with space(s) in it

    I am trying to use REGEXP_INSTR to find a text string with space(s) in it.
    (This is in a Function.)
    Let's say ParmIn_Look_For has a value of 'black dog'. I want to see if
    ParmIn_Search_This_String has 'black dog' anywhere in it. But it gives an error
    Syntax error on command line.
    If ParmIn_Look_For is just 'black' or 'dog' it works fine.
    Is there some way to put single quotes/double quotes around ParmIn_Look_For so this will
    look for 'black dog' ??
    Also: If I want to use the option of ignoring white space, is the last parm
    'ix' 'i,x' or what ?
    SELECT
    REGEXP_INSTR(ParmIn_Search_This_String,
    '('||ParmIn_Look_For||')+', 1, 1, 0, 'i')
    INTO Position_Found_In_String
    FROM DUAL;
    Thanks, Wayne

    Maybe something like this ?
    test@ORA10G>
    test@ORA10G> with t as (
      2    select 1 as num, 'this sentence has a black dog in it' as str from dual union all
      3    select 2, 'this sentence does not' from dual union all
      4    select 3, 'yet another dog that is black' from dual union all
      5    select 4, 'yet another black dog' from dual union all
      6    select 5, 'black dogs everywhere...' from dual union all
      7    select 6, 'black dog running after me...' from dual union all
      8    select 7, 'i saw a black dog' from dual)
      9  --
    10  select num, str
    11  from t
    12  where regexp_like(str,'black dog');
           NUM STR
             1 this sentence has a black dog in it
             4 yet another black dog
             5 black dogs everywhere...
             6 black dog running after me...
             7 i saw a black dog
    5 rows selected.
    test@ORA10G>
    test@ORA10G>pratz
    Also, 'x' ignores whitespace characters. Link to doc:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942
    Message was edited by:
    pratz

  • Scan From String White Space

    i all,
    I'm trying to use Scan From String in order to parse some data coming in from UDP. 
    Input String: ASCII [00 01 02 03 ... FF]
    What I want: s[00 .. 30]  d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    ATTEMPT1
    Format String: %49s%2d%2d%2d
    What I get: s[00-09] RUNTIME ERROR!
    ATTEMPT2
    Format String: %49[^]%2d%2d%2d
    What I get: Only allows first output. Will error out if I use any additional outputs from Scan From String
    ATTEMPT3
    Format String: %49[^(0xFF)]%2d%2d%2d Value in () is ASCII character FF.
    What I get: s[00 .. 30] d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    It appears as though when I use %##[^] it thinks I'm looking for the ENTIRE string so it will not let me add any more Formatting.  If I add a delimiter other than ^ it will run, and it will work presuming that character isn't within the first 49 characters... and I can't guarentee that it won't.
    I'm aware I can parse my string using subsets and whatnot... but Scan From String is so elegant.  It would be great if %S allowed for white space... or if $##[^] would simply take the first ## characters and allow me to Format after that.
    Is there a simple, elegant way to do this?  I wish my dataset was only 3-4 outputs. It'd be ideal if I could.  Thanks.
    Edit:
    It might be more helpful if I provide a less abstract example:
    I have an ASCII Header (Finite Length String), a Sender IP (Finite Length String), a Timestamp, a Message ID (Finite Length Decimal), A Message in ASCII ( '1' actually means 0x31, not 0x01)  And for some ungodly reason... no delimiters.
    So I was HOPING %##s%##s%<%H:%M:%s>t%##d   (With leftover string to be my message)  would work, but if any white space is contained within there... it messes up. 

    I cannot provide exact strings because the string is actually ASCII characters, most of which aren't displayable. 
    I have a string where I have:
    24 ASCII Characters representing 6x U32 Header Data
    13 ASCII characters represening the sender IP (string)
    12 ASCII Characters representing the name of the message (String)
    12 ASCII Characters representing 3x U32 Data
    12 ASCII Characters represneting the name of packet (String)
    12 ASCII Characters representing 12x U8 Data
    256 ASCII Characters represening 256x U8 Data
    etc...
    It would be ideal to simply Scan from the string and output the data with the appropriate data types already assigned instead of splitting string and type casting each individualy.  But if, for example, my header starts with an ASCII representation of a U32 of 2560(decimal) it would look like this:  [00][00][0A][00].  ASCII 0A is considered white space.  So my header would only contain 2 ASCII characters instead of the desired 24.

  • Translate string using hex(0020) in Unicode system.

    Hello all,
    We are facing a problem of the "translate" statement in the Unicode system.
    The original statement goes as follows:
    TRANSLATE BULOG USING WS_STRING1.
    Here  BULOG is a structure and ws_string1 is declared as follows:
    DATA : ws_string1(2) type x value '0020'.
    On compilation in the new system which is Unicode enabled, the above mentioned statement removes all the '#' placed in the structure.
    We tried the following statement instead of the original TRANSLATE statement.
    TRANSLATE BULOG USING SPACE.
    But this statement leaves the '#' unchanged.
    We have already REPLACE statement after converting the structure contents into a string.
    We have also tried the convert methods of the classes CL_ABAP_CONV_IN_CE and CL_ABAP_CONV_OUT_CE.
    Hoping to receive a fast response.
    Thanks in advance.
    Zankruti.

    You might want to read ABAP Help on TRANSLATE:
    Addition 2
    ... USING  pattern
    Effect
    If you specify USING, the characters in text are converted according to the rule specified in pattern.
    pattern must be a character-type data object whose contents are interpreted as a sequence of
    character pairs.
    Your option 1 is not working because type X is "Byte field", technically it's not a character-type. Your option 2 is not working because <pattern> must be a sequence of character pairs (you had just SPACE).
    In Option 1 just change the definition from X to C or STRING.

  • How to pad a string with space or other character

    length 14 string '00000000000155' turn to length 25 string '00000000000155         ' ,use space to pad string trail.
    using following function:
    CONCATENATE '00000000000155' '         ' into lv_string
    but result is the lv_string ='00000000000155',the spaces were not added the string trail.
    how to achieve this purpose padding string.
    pls help me.
    thank you.

    Hi ,
    Not sure what exactly you require, But in my understanding you need to add one more spave after the doknr no. Please refer this code which could be more useful.
    data: lv_objkt like aeoi-OBJKT,
          lv_doknr like draw-doknr,
          lv_dokar like draw-dokar,
          lv_doktl like draw-doktl,
          lv_dokvr like draw-dokvr,
          lv_slen type i.
    lv_dokar = 'DRW'.
    lv_doknr = '00000000000155'.
    lv_doktl = '000'.
    lv_dokvr = '-'.
    CONCATENATE lv_dokar lv_doknr INTO lv_objkt.
    lv_slen = STRLEN( lv_objkt ).
    lv_slen = lv_slen + 1.
    lv_objkt+lv_slen(3) = lv_doktl.
    CONCATENATE lv_objkt lv_dokvr INTO lv_objkt.
    WRITE: lv_objkt.

  • Is it possible to search for strings containing spaces and special characters?

    In our RoboHelp project, there are figures with text labels such as Figure 1, Figure 3-2, etc.
    When I search for "Figure 3" I get all pages containing "Figure" and "3", even if I surround it in quotes.  Similarly, searching for "3-2" treats the '-' character as a space and searches for all pages containing '3' or '2'.
    Is there a way to search for strings containing spaces and special characters?

    In that case I think the answer is no if you are using the standard search engine. However I believe that Zoom Search does allow this type of searching. Check out this link for further information.
    http://www.grainge.org/pages/authoring/zoomsearch/zoomsearch.htm
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Oracle Text Index  - Trailing Search when the String has spaces

    Hi Am trying to use CONTAINS to tune a trailing LIKE search.  But it's not working when the string has spaces in between them
    For e.g in say if table person has column name which has following values
    JOHN
    FRED JOHNSON
    JOHN ROBERTS
    select * from person where name like 'JOHN%'
    Above query will give JOHN and JOHN ROBERTS. If i use CONTAINS As below
    select * from person where CONTAINS(name,'JOHN%',1) > 0
    It brings back all three records. If i remove spaces in column itself, its working bit if i try to remove spaces in Query, i am getting a Text error as i have Text index only on the name column.  I would like to know is it possible to use CONTAINS but get same result set on trailing search as how a normal LIKE will do.
    Below is how i did Index creation
    create index txt_idx1 on person (name)
    indextype is ctxsys.context
    parameters('DATASTORE ctxsys.default_datastore');

    You could use some method, like a multi_column_datastore or user_datastore to append some specific starting characters, then include those in your search, as shown below.
    SCOTT@orcl12c> CREATE TABLE person
      2    (name  VARCHAR2(60))
      3  /
    Table created.
    SCOTT@orcl12c> INSERT ALL
      2  INTO person VALUES ('JOHN')
      3  INTO person VALUES ('FRED JOHNSON')
      4  INTO person VALUES ('JOHN ROBERTS')
      5  SELECT * FROM DUAL
      6  /
    3 rows created.
    SCOTT@orcl12c> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('test_ds', 'MULTI_COLUMN_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('test_ds', 'COLUMNS', '''start ''||name||'' end'' name');
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> create index txt_idx1 on person (name)
      2  indextype is ctxsys.context
      3  parameters('DATASTORE test_ds')
      4  /
    Index created.
    SCOTT@orcl12c> select * from person where CONTAINS(name,'start JOHN%',1) > 0
      2  /
    NAME
    JOHN
    JOHN ROBERTS
    2 rows selected.
    SCOTT@orcl12c>

  • EBS-  How to map search string using wild card

    Hi Gurus
    I got two similar string on bank statement which needs to be mapped to two different posting rules.
    MV-WORLDPAY- 1805 MOTO
    MV-WORLDPAY -1805 WEB
    in above string 1805 could be any no,( it is not fix no). I have tried using different wildcards and symbols like
    +,*,?,# but it is not piciking the right posting rule, also search string use is also activated. so please guide me.
    Many Thanks
    Sam Rathod.

    Hi
    Try keeping the 1st two digits of search string as b;ank. i.e. ############ (12 digits) mapped to __##########. I used underscore to denote balnk space. Using this when you recevie say 000000001618 (12 digits), it will be mapped to 0000001618 (10 digits). Then your interpretation algo will use this 10 digit number.
    Thanks
    Nikhil

  • Subject: extract the string before space

    I have a string say "aquarium a". i want to extract the string appearing before the space and discard the string appearing after space.
    that is the resultant string required is "aquarium". any number of characters can appear after space.
    is it possible to solve using replace() method. i cant hardcode space+character in replace method because number of characters after space is not known.
    Is there any easy way to get the required result

    > i want to check if a string has space in between then
    only this code should run otherwise this code should
    not run. because if a string doesn't have any space
    inbetween then the above code will give error.
    String s = "aquarium a";
    s = s.split("\\s")[0];
    assert s.equals("aquarium");At this point, it would be a good idea to familiarize yourself with the String API. That way, you'll have a better idea how to accomplish your specific requirements.
    ~

  • Padding String with spaces -tried known methods but code not working!

    I am trying to figure out an easy way to pad a string with spaces at the end. The way that definitely works is a for loop where string = string + " "; until string is the length that I need. However, for several dozen strings this is a lot of unnecessary overhead. I've done some research and tried a few different things - yet none of them seem to actually pad the string.
    import org.apache.commons.lang.StringUtils;
    public class Test
         public static void main(String[] args)
              String one = "1234";
                    //print string at current lenght
              System.out.println(one+"*");
                    //try padding using String.format (in padRight method below)
              one = padRight(one,(8-one.length()));
              System.out.println(one+"*");
                    one="1234";
                    //try padding using StringUtils
              String tmp = StringUtils.rightPad(one, (8-one.length()));
              System.out.println(tmp+"*");
         private static String padRight(String s, int n)
              return String.format("%1$-" + n + "s", s);
    }I've researched and these are the two most common methods people are suggesting. I am using java 1.5 so the String.format should work.. however, when I run it (I use JBuilder) the output is always "1234*".... after I try to pad it the output should be "1234 *" (with 4 spaces between the 4 and *) . Any suggestions is greatly appreciated! Thanks in advance.

    Wow, I completely botched that... uncle_alice, thank you for clearing that up for me.
    pbrockway2 - thank you, I actually did peruse the Formatter documentation - I would never post without researching something first... but I must have read it with one eye shut because walked away with the impression that I needed to submit the difference. I obviously misunderstood the documentation.
    Thanks!

  • Padding a string with spaces

    How do you pad a string w spaces using "Format into a string" w/o typing /s/s/s/s/s for say 5 spaces ?
    Solved!
    Go to Solution.
    Attachments:
    printed output.PNG ‏6 KB
    wire diagram.PNG ‏11 KB

    Hi Clint,
    this way:
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Breadcrumbs containing string with spaces - generating the anchor

    so I have a website that contains a 'breadcrumbs' line that allows users to click on it, and take them back to the parent page
    eg. "jewellery"
    I simply suffix this string with ".cfm" to generate the anchor / filename
    what's the best way to deal with strings containing spaces?
    eg. "birthday cards"
    As good practice I want to use a more compatiable filename that doesn't include spaces
    eg. "birthday_cards.cfm"
    is the REPLACE command ok to use ? or is preferrable to add an additonal field to the table, called "filename" and store the exact filename in there ?

    option 1
    use quotes like href="http:\\....."
    option 2
    convert spaces to %2B

  • Trimming Movies = Lost Disk Space?

    Hi Guys,
    I'm using FCE4. I've captured a bunch of clips from old 8mm tapes and have them in a bin in FCE. I right click on them, choose "open in editor" to get them in a quicktime window. Then I trim the clip to just the portion I want to keep and choose "Trim to Selection." Quicktime lops off the beginning and end and bam - I've got only the video I want.
    If I open the movie inspector within quicktime, it shows me that the newly trimmed video is taking up less space than it used to. However, if I look at the video file in the finder, the finder shows that the video is still taking up the same amount of space as it did before I trimmed it.
    This is a problem, because I have hundreds of videos to trim and the wasted space is going to add up. What am I doing wrong? Thanks!
    -Bryan Jones

    After you trim it try doing a Save As. You might also try this question on the QuickTime forum, where there are people you work with that application.

  • Replace string by space

    I would like to replace all ',' appear in a strng by space. So, i use
    replace all occurrences of ',' in tempStr with space.
    But, the outcome is all pattern are replaced, and concatenate together. For example, i have string
    tempStr = '1,2,3,4,5,6,7'
    But the result is
    tempStr = 1234567
    How can i replace the string by space. thanks!

    Hi,
    Try this.
    data : tempstr type string,
    temp(2) type c.
    tempStr = '1,2,3,4,5,6,7'
    temp = ', '.
    Translate tempstr using temp.
    Write tempstr.
    Regards,
    Mohaiyuddin

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Local Interfaces Support in 9.0.2 Release 2?

    Does Oracle9iAS 9.0.2 Release 2 support Local Interfaces? The reference I found is as follows: from http://otn.oracle.com/tech/java/oc4j/htdocs/oc4j-how-to.html: Please note that some of the How-To's only work with later versions of Oracle9iAS Contai

  • Quan field in lsmw

    hi SDN ers, I have created one lsmw for open sales order using bapi. Every field in the file updated datas successfully except quantity. i declared quantity field as char(15). Reading and converting the data is right. When executing in idoc its creat

  • Having in proper cursor movement when view the discoverer output

    Hi all, When I try to view the discoverer output in the discovere desktop by using the keyboard tab key to move from one column to another column, the data was not displayed properly. It is just like not enough memory, but if I used the mouse to scro

  • Connecting through RADIUS to install arch??

    hi everyone! i have one problem. i want to install arch linux, but since i live in student home, the network is supervised and controlled with kerio control firewall/AAA. each time i want to access internet i need to enter the username and password b

  • Tomcat suddenly won't work

    My tomcat 4.0.3 worked great until thursday, I was making some operating system changes and it killed my tomcat. When i run catalina debug, I get the following error: C:\JavaDevelopment\jakarta-tomcat-4.0.3\bin>catalina debug Using CATALINA_BASE: c:\