Regular Expression To Remove Leading While Space

Hii
I have a data like this
20200 Kuala Terengganu
Terengganu
Luala Terengganu
I want to remove the Leading white space in the Second line .Can anybody help me to
write regular expression for this?
I want my result like the following :
20200 Kuala Terengganu
Terengganu
Luala Terengganu
Thanks In Advance
Jim John

But there's no difference between two group of lines which you posted. Could you please format your input and desired output with please?
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Using Regular Expressions To Remove Characters JDK 1.4

    I want to write a regular expression to remove all commas in a string of text.
    string is:
    1,000
    or 1,000,000
    I want it to return 1000 and 1000000.
    I have tried some but I am just starting with Regular Expressions.
    Please Help!

    Try this tutorial: Linux : Education : Tutorials
    Using regular expressions
    David Mertz
    President, Gnosis Software, Inc.
    September 2000
    http://www-105.ibm.com/developerworks/education.nsf/linux-onlinecourse-bytitle/6C2B4863702F592B8625696200589C5B?OpenDocument

  • Regular Expression for Removing a space after the a... tag?

    Hi there,
    I'm fairly new to using Regular Expressions, but am in need of one that will help me find all <a...> tags that have a space immediately following that tag and replace it with the exact same tag, but no space following the <a...> tag.
    So, for example, a regular expression that will find:
    <a href="somelink.html"> Somelink</a>
    as well as:
    <a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('sub-nav_button_professional_portal','','images/sub-nav_button_ professional_portal_f2.png',1)"> Somelink</a>
    And just remove the space appearing as part of the hyperlink.  Does anyone know how to accomplish this?

    Thought of that, but it would remove spaces from crucial areas of my pages.  For example, conditional logic within a script, like:
    for (i = 0; i > (a.length - 2); i += 3)
    would become:
    for (i = 0; i >(a.length - 2); i += 3)
    While that wouldn't pose a huge problem, I'm messing up the syntax in order to fix something else, which is why I wanted to go the route of a regular expression.  I need to replace all "<a ...> " (space included) tags with "<a ...>" and make sure that the properties within the <a> tag stay in tact.

  • Regular Expression to remove space in HTML Tag

    Hello All,
    My HTML string is like below.
    select '<CityName>RICHMOND</CityName> 
    <StateCd>ABCD CDE 
    <StateCd/>
    <CtryCd>CAN</CtryCd>
    <CtrySubDivCd>BC</CtrySubDivCd>' Str from dual
    Desired Output is
    <CityName>RICHMOND</CityName><StateCd>ABCD CDE 
    <StateCd/><CtryCd>CAN</CtryCd><CtrySubDivCd>BC</CtrySubDivCd>
    i.e. want to remove those spaces from tag value area having only spaces otherwise leave as it is. Please help to implement the same using Regular expression.

    Hi,
    It's unclear what you want.  This site seems to be formatting your message in some odd way.
    Post a statement like
    SELECT '...' FROM dual;
    without any formatting, to show your input, and post the exact output you want friom that, with as little formatting as possible.  It might help if you use some character like ~ instead of spaces (just for posting; we'll find a solution that works for spaces).
    To remove the text that consists of spaces and nothing else between the tags, you can say
    REGEXP_REPLACE ( str
                   , '> +<'
                   , '><'
    How is this string being generated?  Maybe there's some easier, more efficient way to keep the bad sub-wrtings out of the string in the first place.

  • Regular Expression for replacing Leading Spaces

    I don't claim to be any expert on Regular Expressions and even after reading CD's introduction to Reg Exp, I still can't figure out this one which I'm sure must be very basic.
    I want to replace all the leading spaces in a string with "." chrs. I could do this using the common replace/substr/instr functions, but I reckoned it would be possible in a single regular regexp_replace call.
    So far I've got this...
    SQL> select regexp_replace('      FRED BLOGS    WAS HERE    ', '^([:space:])*', '.')
      2  as result
      3  from dual;
    RESULT
    .      FRED BLOGS    WAS HERE
    SQL>Which is replacing the start of line with a "." and not the spaces.
    But I want my result to be:-
    RESULT
    ......FRED BLOGS    WAS HERE
    SQL>Cheers

    That was very good solution .
    Can you explain me the significance of "| " in the code, other things I could trace out.
    I try to run the code with the 2 cases
    when I give a space after | symbol it prints the * many times
    SQL> SELECT col1, REGEXP_REPLACE(col1, ' ([^ ]+.*)|','*\1')
    2 FROM (SELECT ' FRED BLOGS WAS HERE ' col1 FROM dual );
    COL1
    REGEXP_REPLACE(COL1,'([^]+.*)|','*\1')
    FRED BLOGS WAS HERE
    *FRED BLOGS    WAS HERE
    SQL> SELECT col1, REGEXP_REPLACE(col1, ' ([^ ]+.*)| ','*\1')
    2 FROM (SELECT ' FRED BLOGS WAS HERE ' col1 FROM dual );
    COL1
    REGEXP_REPLACE(COL1,'([^]+.*)|','*\1')
    FRED BLOGS WAS HERE
    ******FRED BLOGS WAS HERE

  • File Content Conversion Removes Leading Blank/Space

    I'm having a problem where file content conversion is trimming leading blanks/space/whitespace from fields when reading in the inbound file.  I've seen where people have posted that you need to use fieldContentFormatting to prevent content conversion from stripping the leading/trailing whitespace.  I added that parameter to my list (see below example) but it still appears to be trimming the leading whitespace.  Look forward to hearing your thoughts.  Here are the details:
    I'm using fixed length file content conversion for Sender File Adapter (SP15).  I have the following parameters set:
    Document Name = MaterialData
    Recordset name = item
    Recordset Structure = MaterialLine, 1
    I have:
    MaterialLine.fieldNames = matno_external, mat_description
    MaterialLine.fieldFixedLengths = 40, 40
    MaterialLine.fieldContentFormatting = nothing, nothing
    The following is the input file (notice spaces prior to second occurrence of material numbers)
    ZED00000001                             AIMS LIGHT A
    ZED00000001                            AIMS LIGHT B
    ZED00000002                             AIMS SWITCH A
    ZED00000002                            AIMS SWITCH B
    ZED00000003                             AIMS SEMICONDUCTOR A
    ZED00000003                            AIMS SEMICONDUCTOR B
    The following is the source XML after file content conversion from SXMB_MONI (note spaces no longer exist in matno_external tag).
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns:MaterialData xmlns:ns="http://xxxxxxx.com/yyy/test">
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000001</matno_external>
      <mat_description>AIMS LIGHT A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000001</matno_external>
      <create_date>10/09/06</create_date>
      <mat_description>AIMS LIGHT B</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000002</matno_external>
      <mat_description>AIMS SWITCH A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000002</matno_external>
      <mat_description>AIMS SWITCH B</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000003</matno_external>
      <mat_description>AIMS SEMICONDUCTOR A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000003</matno_external>
      <mat_description>AIMS SEMICONDUCTOR B</mat_description>
      </MaterialLine>
      </item>
      </ns:MaterialData>

    Thanks all for your attempts but I figured it out and wasn't this the biggest case of irony.
    Here I was trying to prevent leading spaces from being trimmed in the loading of my file and my problem was that when I typed:
    MaterialLine.fieldContentFormatting
    I actually left a "blank" at the end of the "g" in Formatting.  Apparently XI didn't like that and neither gave me a runtime or compile error.  Anyway I found this and though I'd share in case anyone else encounters it.  I removed the blank and all is working now.

  • Regular expression to remove SIDs from list

    Hey everyone so I have a script and in it I try to find the current user, as well as the last user. Currently I'm using a regular expression to throw the System account SIDs and other things like that out of the list. However this doesn't seem to be taking
    SQL SIDs out of my list ie. ReportServer$LOCAL with the SID S-1-5-80-4264962431-3932693095-1576469926-235475122-2208986020
    What's the best way to get only user SIDs?
    Here's what I have so far:
    $Win32User = Get-WmiObject -Class Win32_UserProfile -ComputerName $Computer
    $Win32User = $Win32User | Where-Object {($_.SID -notmatch "^S-1-5-\d[18|19|20]$")}
    $Win32User = $Win32User | Sort-Object -Property LastUseTime -Descending
    $LastUser = $Win32User | Select-Object -First 1
    When I can this it breaks since there is no actual user tied to this SID:
    $UserSID = New-Object System.Security.Principal.SecurityIdentifier($LastUser.SID)
    $User = $UserSID.Translate([System.Security.Principal.NTAccount])
    Thanks for any help!!

    Start cmd.exe as your domain user and run whoami /user to get your own SID. You will get something like this:
    USER INFORMATION
    User Name SID
    ========================= =============================================
    DEMOSYSTEM\CustomAccount1 S-1-5-21-3419697060-3810377854-678604692-1000
    The last part of the SID, in this case 1000, is called RID. When you create a new user or computer object in your domain, only the RID will be different from your own SID. The RID starts on 1000 and increments as you create new objects.
    If you are only interested in user accounts from the same domain as your user, you can use a regex like this, only based on your own SID:
    $_.SID -match '^S-1-5-21-3419697060-3810377854-678604692-[\d]{4,10}$'

  • Use Regular Expressions to remove open/close anchor tags but leave the text contained within alone

    I have a large file with lots of anchor tags.  Many of the anchor tags have no HREF specified and do nothing.  They aren't hurting anything, either, but I'd like to get rid of them, leaving the anchor tags that do have HREF alone, and leaving the text between the tags alone.  Here's an example: <a>A resident or municipality may seek to vacate 25.01.01</a>.
    I've come up with this to identify those tags: <\a>(.)*</\a>  and it works, it finds them, but what should I put in the Replace area in order to remove the open/close tags but leave the text as it is?

    I'm a reg ex idiot. So I use the Search Specific Tag feature whenever I can.  See screenshot, hit Replace All.  But please do this on a backed-up document to be sure it does what you want.
    Nancy O.

  • Regular Expression to Remove Part of URLs

    I need to accomplish the following:
    Search for all URLs that contain "
    http://www.mycompany.com/dept/catalogs/"
    and strip off anything past the .../catalogs/"
    Basically, I have 3000+ links that begin with "
    http://www.mycompany.com/dept/catalogs/"
    and I need to strip whatever they may have after the .../catalogs/
    piece of the URL.
    Anyone know of an automatic way to accomplish this?
    Thanks in advance!

    In what programming environment are you doing this?
    In DW's Find/Replace?
    If so, then try this carefully on a test page, as I have not
    tested it:
    Find:
    http:\/\/www\.mycompany\.com\/dept\/catalogs\/[^\"]*\"
    Replace with:
    http://www.mycompany.com/dept/catalogs/"
    If you need this in some other environment, let us know.
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • Regular expression - removing emails

    Hi,
    How to use regular expressions to remove email addresses from
    html files ?
    Thanks in advance.
    Maxcx

    maxcx wrote:
    > Hi,
    > How to use regular expressions to remove email addresses
    from html files ?
    > Thanks in advance.
    > Maxcx
    Do you want to remove the email address, or to remove the
    whole <a>
    tag containing same?
    Mick

  • Regular expression - find repeating +++ signs

    I'm trying to use regular expressions to remove duplicate +++ signs in a string. When I test my pattern using the expresso test (www.ultrapico.com) it parses the string correctly, in Java 1.5 it doesn't work. .. mp.matches() is always false. Any suggestions would be appreciated.
    finalLongstring = "TTL1,clip1+TTL2+++clip3,TTL4,clip4,TTL5,clip5+TTL6+clip6+TTL7+clip7,TTL8,clip8,TTL9,clip9,TTL10,clip10,TTL11,clip11,TTL12,clip12,TTL13,clip13+TTL14+clip14,TTL15,clip15,TTL16,clip16,TTL17,clip17,TTL18,clip18,TTL19,clip19,TTL20,clip20,TTL21,clip21,TTL22,clip22,TTL23,clip23,TTL24,clip24,TTL25,clip25,TTL26,clip26,TTL27,clip27,TTL28,clip28,TTL29,clip29";
    Pattern multiplePunctuation=null;
              multiplePunctuation=Pattern.compile("[,+]{2,6}");
              //                                     |  |
              //                                     |  2 or more times
              //                                     a comma or plus character
              Matcher mp=multiplePunctuation.matcher(finalLongstring);
              if(mp.matches()){
                   finalLongstring=mp.replaceAll("+");
    /code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Answere in your other thread.
    http://forum.java.sun.com/thread.jspa?threadID=5143654

  • Regular expression on form value

    I have a form value that I need to add a regular expression to the end so I can pick up any characters after the form value.
    Example if someone enters Jones then I want to make sure the value could also search Jones Jr or Jones Sr.
    Basically add a space and any characters a-z to the form value.
    Here is my attempt but lost on regular expression part:
    REReplace ("form.myvalue","[[:space:]]","Not sure what the regular expression would be here?","ALL")

    This will replace "Jones Jr" and "Jones Sr" in the following text:
    "this is a test text Jones Jr and Jones Sr"
    ReReplaceNoCase("your_text_in_which_you_want_to_replace",
    "#form.myvalue#[[:space:]][a-z]*", "replacement_text", "ALL")
    Mack

  • Regular Expression with comma and encapsulated charaters

    Would appreciate some help. Looking for a regular expression to remove comma's from encapsulated text as follows
    For example
    - Input
    1,"This is a string, need to remove the comma",Another text string,10
    - Required output
    1,"This is a string; need to remove the comma",Another text string,10
    Have tried to use the REGEXP_REPLACE but could not grasp the pattern matching.
    Thanks John

    John Heaton wrote:
    Thanks for the solution,this works great for a single field encapsulated by " and containing ,. I am parsing several different file definitions so it would need to cascade through the string for a undetermined number of times and replace all occurrences. Then try (performance-wise) MODEL solution:
    {code}
    with t as (
    select '1,"This is a string, need to remove the comma",Another text string,10' txt from dual union all
    select '1,"remove this comma,",Another text string,10,"remove this comma,",xxx,"remove this comma,",11' txt from dual
    select txt_original,
    txt
    from t
    model
    partition by(row_number() over(order by 1) p)
    dimension by(1 rn)
    measures(txt txt_original,txt,0 quote)
    rules
    iterate(
    1e9
    until(
    iteration_number + 1 = length(txt[1])
    quote[1] = case substr(txt[1],iteration_number + 1,1)
    when '"' then quote[1] + 1
    else quote[1]
    end,
    txt[1] = case substr(txt[1],iteration_number + 1,1)
    when ',' then case mod(quote[1],2)
    when 1 then substr(txt[1],1,iteration_number) || ';' || substr(txt[1],iteration_number + 2)
    else txt[1]
    end
    else txt[1]
    end
    TXT_ORIGINAL TXT
    1,"This is a string, need to remove the comma",Another text string,10 1,"This is a string; need to remove the comma",Another text string,10
    1,"remove this comma,",Another text string,10,"remove this comma,",xxx,"remove this comma,",11 1,"remove this comma;",Another text string,10,"remove this comma;",xxx,"remove this comma;",11
    SQL>
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Expand a Regular Expression

    How do I expand a regular expression?
    I mean if I have '12[3-5]' as my starting point. I want to see:
    result
    12[3-5]
    123
    124
    125
    Any help will be appreciated.
    Thanks

    I'd say you need a procedure that "interprets" a regular expression for generating all available string - good luck on this one. For short strings you could also try a "brute force" string generator that generates all possible combinations and filters them through a regular expression:
    DECLARE
      PROCEDURE check_regex(
        p_regex   IN VARCHAR2
      , p_max_len IN NUMBER
      IS
        c_chars CONSTANT VARCHAR2(10) := '0123456789';
        TYPE t_counter IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
        v_counter t_counter;
        v_exit   BOOLEAN := FALSE;
        v_string VARCHAR2(255);
      BEGIN  
        -- init loop
        FOR i IN 1..p_max_len
        LOOP
          v_counter(i) := 1;
        END LOOP;
        -- show regular expression
        DBMS_OUTPUT.put_line(p_regex); 
        WHILE NOT v_exit
        LOOP
          -- start generation
          v_string := '';
          FOR i IN 1..p_max_len
          LOOP
            v_string := v_string || SUBSTR(c_chars, v_counter(i), 1);
          END LOOP;
          -- filter the generated string through the regular expression
          IF REGEXP_LIKE(v_string, p_regex) THEN
             DBMS_OUTPUT.put_line(v_string); 
          END IF;
          -- increment loop
          FOR i IN REVERSE 1..p_max_len
          LOOP
            v_counter(i) := v_counter(i) + 1;     
            IF v_counter(i) > LENGTH(c_chars) THEN
               IF i > 1 THEN
                  v_counter(i) := 1;
               ELSE
                  v_exit := TRUE;  
               END IF;
            ELSE
               -- no further processing required
               EXIT;  
            END IF;  
          END LOOP;        
        END LOOP; 
      END check_regex;
    BEGIN
      check_regex(p_regex => '12[3-5]', p_max_len => 3);
    END;  If you come up with a better solution, I'd be interested.
    C.

  • Match leading spaces in a regular expression?

    I have the following regular expression:
    ^[^0-9A-Z][^0-9A-Z ]$
    For some reason, it does not match leading spaces, so " A" is considered no match, even though space is obviously neither a digit or an uppercase letter...
    [Edit] Also, it doesn't seem to match case properly - "ab" is matched, but not "Ab" or "aB"...

    Then remove the not's ^
    From : ^[^0-9A-Z][^0-9A-Z ]$
    To     : ^[0-9A-Z][0-9A-Z ]$
    The first ^ indicates the beginning of the line and $ the end of the line.  The pattern will only work with two characters on the line.  If you have more than two characters on the line then use this
    To     : ^[0-9A-Z][0-9A-Z ]
    jdweng

Maybe you are looking for

  • Apple remote desktop not working

    Just upgraded to Mavericks and can not use apple remote desktop.  I bought my copy of ARD from the store.  Anyway of getting this fixed?

  • Using Windows won't turn off display

    When I am using Windows on my MacBook, I have set my Windows power options to turn off the monitor after 1 minute of not being used. The display never turns off. Is this a Windows or a MacBook problem? I tried setting it to 5mins, 10mins... Nothing w

  • BOR for F-53 AR Module Outgoing Post Payment

    Hi, I want to trigger the workflow evertime Outgoing Post Payment has been posted. in transaction F-53. Please advise which BOR that i can use. Thank You and Best Regards Fernand Lesmana

  • Internet modem hangups

    My internet modem continually hangs up. After a year and 3 times in the shop, plus modem being replaced, as well as MLB and Ram, and software reinstalled, it is still doing this. A new phone line was put in. An Apple Consultant said it could be cause

  • ITunes killing my wireless

    Installing iTunes 9.1.1.12 64-bit on my HP 5380sc (Win7 64-bit) kills my wireless connection. Using Win restore point prior to installing iTunes, makes my wireless work again. I have tried this several times with the same result. /Johnny