Split a string when a url is found

Hello

I am trying to find a URL within a string and it (the text before the link itself and the following text) divided into distinct parts. I tried the split (...) method, but never adds the URL as one of the parts of the split. Is it possible to do? That's what I'm currently using:
public static List<String> findUrls(String input) {
     List<String> result = new ArrayList<String>();
     Pattern pattern = Pattern.compile("\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]");
     Matcher matcher = pattern.matcher(input);
     while (matcher.find()) {
          result.add(matcher.group());
     }
     return result;
}
I can't understand how to split like that, but I tried this, which works, just not as I want (showing the first part, end of game and the link):
public void findUrl(String input) {
        String[] test = input.split("\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]");
        for (int i = 0; i < test.length; i++) {
             System.out.println(test);
}
}
The output I get when doing the findUrl(...) method is:
System.out.println (Regex.findUrl ("just testing http://www.google.com/ this split of the string"));
is
just test
This string of split
Any suggestions or help?

Thanks,

aeternaly                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

It's ugly, and I know there's a way easier and cleaner to do and I don't know if that's what you want, but you may be able to use it as a starting point:

"xxx abc xxx def xxx xxx ghi jkl   xxx".split("((?<=xxx)\\s++)|(\\s++(?=xxx))")

// gives

["xxx", "abc", "xxx", "def", "xxx", "xxx", "ghi jkl", "xxx"]

where xxx is your URL scheme. You can keep the spaces around your matches to that model you rid of occurrences of {noformat} \\s++ {noformat}, but this also includes the empty string at the beginning of the sequence and the spaces between the consecutive games:

["", "xxx", " abc ", "xxx", " def ", "xxx", " ", "xxx", " ghi jkl   ", "xxx"]

Also, I think that your URL scheme is too complex. Why not use something much more simple that will work in the majority of cases?

pat = "(http://|www\\.)\\S++"
input = "http://www.google.com/a/b?c=d&e=f abc www.bibblebobble.net def  ghi   www.bibblebobble.net    http://honkhonk";
input.split(String.format("((?<=%s)\\s++)|(\\s++(?=%s))", pat, pat))

Result: ["http://www.google.com/a/b?c=d&e=f", "abc", "www.bibblebobble.net", "def  ghi", "www.bibblebobble.net", "http://honkhonk"]

Although I suspect that's what you were trying to do, but maybe you didn't know that you could use

\S

means "anything but a space" and

+

to mean "one or more".

http://download.Oracle.com/javase/tutorial/essential/regex/
http://www.regular-expressions.info/tutorial.html

EDIT: I probably account for the https protocol and ignore case. Must be something like that, but I have not tested:

pat = "(?i)(http(s?)://|www\\.)\\S++"

Edited by: jverd August 6, 2011 14:09

Tags: Java

Similar Questions

  • HELP needed on 'Advanced Photo Album' Flash CS5 model Io-error: url not found

    Hello people!

    I had a problem on my slide show I did with the "Advanced Photo Album" model. This problem is not new, I found a thread here with similar problems, but it did not help me. I had the same code as the people in the other forum, but my problem is not the download problem. but I can't even see the images when I test the movie. The rest works fine, it shows the titles of the image on the right, and in fact "slides". The only problem is I get the error:

    #2044 error: ioError unverarbeitet. Text = Error #2035: Die URL wurde nicht found. URL: file:///C|/Users/User/Desktop/FenzBildergalerie/image1.JPG

    (for those who don't speak German: it is said: IO error not handled. text = Error #2035:Url not found.)

    I followed this tutorial here and did everything in exactly the same way.

    all my images are named image1.jpg and so forth and are all in the same folder as the .swf and .fla here files:

    folderdirectory.jpg

    AND: I followed the advice of the other forum:

    "To ensure that the images are in the same location as the swf file, does not matter the fla file.  Also I suggest that you manually rename one of the images, rename the file name and extension.  My previous question to have to the hardcode the. JPG as all caps was weird because on my system, they presented as .jpg.  Again, I would renameing the first and second image with a manual .jpg typed in the name of the file, not only the code as3.

    PS also try to change the as3 of the 3rd and 4th image code in. JPG to see if that helps. »

    I have tried every single possibility in renamed:

    Image1.jpg

    Image1. JPG

    Image1. JPEG

    img1jpg

    img1. JPG

    It does not at all...

    still, it looks like this:

    galleryissue.jpg


    Here is my code:

    Import fl.data.DataProvider;
    Import fl.events.ListEvent;
    Fl.transitions import. *;
    Fl.controls import. *;

    USER CONFIGURATION SETTINGS.
    var secondsDelay:Number = 5;
    var autoStart:Boolean = true;
    var transitionOn:Boolean = true; true, false
    var transitionType:String = "Fade"; Blinds, Fade, Fly, Iris, Photo, PixelDissolve, rotate, Squeeze, wipe, Zoom, random
    var hardcodedXML:String = "< photos > < image title ="View"> image1.jpg < / image > < image title ="Badesteg"> image2.jpg < / image > < image title ="Location"> image3.jpg < / image > < image title ="Kochecke"> image4.jpg < / image > < image title = 'Sofa' > image5.jpg < / image > < image title ="Garden"> image6.jpg < / image > < image title ="Liegebereich"> image7.jpg < / image > < image title ="Room"> image8.jpg < / image > < image" title = "Badekar" > image9.jpg < / image > < image title = "Bett" > image10.jpg < / image > < / photos > «;»
    THE END USER CONFIGURATION SETTINGS

    DECLARE VARIABLES AND OBJECTS.
    var imageList:XML = new XML();
    var currentImageID:Number = 0;
    var imageDP:DataProvider = new DataProvider();
    var slideshowTimer:Timer = new Timer ((secondsDelay*1000), 0);
    REPORT AS FINISHED

    HARDCODED FOR XML CODE =.
    imageList = XML (hardcodedXML);
    fl_parseImageXML (ImageList);
    END OF THE HARD-CODED XML

    EVENTS =.
    imageTiles.addEventListener (ListEvent.ITEM_CLICK, fl_tileClickHandler);
    function fl_tileClickHandler(evt:ListEvent):void
    {
    imageHolder.imageLoader.source = evt.item.source;
    currentImageID = evt.item.imgID;
    }
    playPauseToggle_mc.addEventListener (MouseEvent.CLICK, fl_togglePlayPause);
    function fl_togglePlayPause(evt:MouseEvent):void
    {
    If (playPauseToggle_mc.currentLabel is "play")
    {
    fl_startSlideShow();
    playPauseToggle_mc.gotoAndStop ("pause");
    }
    Else if (playPauseToggle_mc.currentLabel == "Paused")
    {
    fl_pauseSlideShow();
    playPauseToggle_mc.gotoAndStop ("play");
    }
    }
    next_btn.addEventListener (MouseEvent.CLICK, fl_nextButtonClick);
    prev_btn.addEventListener (MouseEvent.CLICK, fl_prevButtonClick);
    function fl_nextButtonClick(evt:MouseEvent):void
    {
    fl_nextSlide();
    }
    function fl_prevButtonClick(evt:MouseEvent):void
    {
    fl_prevSlide();
    }
    slideshowTimer.addEventListener (TimerEvent.TIMER, fl_slideShowNext);
    function fl_slideShowNext(evt:TimerEvent):void
    {
    fl_nextSlide();
    }
    EVENTS OF THE END

    FUNCTIONS AND LOGIC =.
    function fl_parseImageXML(imageXML:XML):void
    {
    var imagesNodes:XMLList = imageXML.children ();
    for (var i in imagesNodes)
    {
    var imgURL:String = imagesNodes [i];
    var imgTitle:String is imagesNodes [i] .attribute ("title");.
    imageDP.addItem ({label: imgTitle, source: imgURL, imgID:i});})
    }
    imageTiles.dataProvider = imageDP;
    imageHolder.imageLoader.source = imageDP.getItemAt (currentImageID) .source;
    title_txt. Text = imageDP.getItemAt (currentImageID) .label;
    }
    function fl_startSlideShow (): void
    {
    slideshowTimer.start ();
    }
    function fl_pauseSlideShow (): void
    {
    slideshowTimer.stop ();
    }
    function fl_nextSlide (): void
    {
    currentImageID ++;
    If (currentImageID > = imageDP.length)
    {
    currentImageID = 0;
    }
    if(transitionOn == true)
    {
    fl_doTransition();
    }
    imageHolder.imageLoader.source = imageDP.getItemAt (currentImageID) .source;
    title_txt. Text = imageDP.getItemAt (currentImageID) .label;
    }
    function fl_prevSlide (): void
    {
    -currentImageID;
    If (currentImageID < 0)
    {
    currentImageID = imageDP.length - 1;
    }
    if(transitionOn == true)
    {
    fl_doTransition();
    }
    imageHolder.imageLoader.source = imageDP.getItemAt (currentImageID) .source;
    title_txt. Text = imageDP.getItemAt (currentImageID) .label;
    }
    function fl_doTransition (): void
    {
    If (transitionType is "Blinds")
    {
    TransitionManager.start (imageHolder, {type: stores, direction: Transition.IN, duration: 0.25});
    } ElseIf (transitionType == 'Fade')
    {
    TransitionManager.start (imageHolder, {type: Fade, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == 'Fly')
    {
    TransitionManager.start (imageHolder, {type: Fly, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == "Iris")
    {
    TransitionManager.start (imageHolder, {type: Iris, direction: Transition.IN, duration: 0.25});
    } ElseIf (transitionType == 'Photo')
    {
    TransitionManager.start (imageHolder, {type: Photo, direction: Transition.IN, duration: 0.25});
    } ElseIf (transitionType == "PixelDissolve")
    {
    TransitionManager.start (imageHolder, {type: PixelDissolve, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == "Rotate")
    {
    TransitionManager.start (imageHolder, {type: turn, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == 'Squeeze')
    {
    TransitionManager.start (imageHolder, {type: Squeeze, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == "Wipe")
    {
    TransitionManager.start (imageHolder, {type: wipe, direction: Transition.IN, length: 0.25});
    } ElseIf (transitionType == 'Zoom')
    {
    TransitionManager.start (imageHolder, {type: Zoom, direction: Transition.IN, duration: 0.25});
    } ElseIf (transitionType == "Random")
    {
    var randomNumber:Number = Math.round (Math.random () * 9) + 1;
    Switch (NombrAl) {}
    case 1:
    TransitionManager.start (imageHolder, {type: stores, direction: Transition.IN, duration: 0.25});
    break;
    case 2:
    TransitionManager.start (imageHolder, {type: Fade, direction: Transition.IN, length: 0.25});
    break;
    case 3:
    TransitionManager.start (imageHolder, {type: Fly, direction: Transition.IN, length: 0.25});
    break;
    case 4:
    TransitionManager.start (imageHolder, {type: Iris, direction: Transition.IN, duration: 0.25});
    break;
    case 5:
    TransitionManager.start (imageHolder, {type: Photo, direction: Transition.IN, duration: 0.25});
    break;
    case 6:
    TransitionManager.start (imageHolder, {type: PixelDissolve, direction: Transition.IN, length: 0.25});
    break;
    case 7:
    TransitionManager.start (imageHolder, {type: turn, direction: Transition.IN, length: 0.25});
    break;
    case 8:
    TransitionManager.start (imageHolder, {type: Squeeze, direction: Transition.IN, length: 0.25});
    break;
    case 9:
    TransitionManager.start (imageHolder, {type: wipe, direction: Transition.IN, length: 0.25});
    break;
    case 10:
    TransitionManager.start (imageHolder, {type: Zoom, direction: Transition.IN, duration: 0.25});
    break;
    }
    } else
    {
    trace ("error - transitionType not recognized");
    }
    }
    if(autostart == true)
    {
    fl_startSlideShow();
    playPauseToggle_mc.gotoAndStop ("pause");
    }
    END OF FUNCTIONS AND LOGIC

    I would really appreciate your help!

    Best regards, eva

    PS. I m of the Austria, if you prefer to speak German

    If this image you show first in the first display shows the folder of your images, then your code is not agree with the names of these images, and one of them be wrong will kick you get the error message...  ". JPG 'and '. JPEG"is not the same as".jpg ".  You should change all your image filenames to match with the code so that you have a consistent naming of your files.

    var hardcodedXML:String ="Image1.jpgImage2.jpgimage3.jpgimage4.jpgimage5.jpgimage6.jpgimage7.jpgimage8.jpgimage9.jpgimage10.jpg";

  • Error #1119: URL Not Found. Blues...

    I am building a dynamic scrolling photo gallery. I got the 1119 annoying error when I test my movie fla. He reports that ' basename = root.basename; ' is not defined. Laughing out loud... Here is my code...

    Of Scene1

    var basename:String = "family";

    Inside of the MC thumb_template

    var id:Number;
    var basename:String;

    basename = root.basename;

    var thumbURL:String = "images/" +  basename + id + ".jpg";

    var imageLdr:Loader = new Loader();
    var imageURLReq:URLRequest = new URLRequest(thumbURL);
    imageLdr.load(imageURLReq);
    imageLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

    function imageLoaded(event:Event):void {
        loadTarget.addChild(imageLdr.content);
    }

    I tried to use

    baseName = MovieClip (root) ["basename"];

    but it gave me error 2035: URL not found. Could someone tell me what I'm doing wrong? Thank you and happy new 2011

    Is like closing your eyes and saying that you don't see any problem.  the problem is still there.

  • Help URL Not Found...

    =====================

    FLASH CODE

    =====================

    import flash.events. *;
    import flash.net.URLLoader;
    import flash.net.URLRequest;

    var xmlRequest:URLRequest = new URLRequest("Images/imageData.xml");
    var xmlLoader:URLLoader = new URLLoader (xmlRequest);
    var imgData:XML; image data
    var imgLoader:Loader;

    var rawImg:String;
    var imgNum:Number = 0;

    xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded);

    function xmlLoaded(event:Event):void {}
    imgData = new XML (event.target.data);
    imgData.ignoreWhitespace = true;
    rawImg = imgData.image [imgNum] .imgURL;

    imgLoader = new loader;
    imgLoader.load (new URLRequest (rawImg));
    imgHolder_mc.addChild (imgLoader);
    trace (XMLDATA);
    }

    ==============

    XML

    ==============

    <? XML version = "1.0" encoding = "utf-8"? >
    < fruit >
    < image >
    < imgTitle > Dragon fruit. < / imgTitle >
    dragon_fruits.jpg < imgURL > < / imgURL >
    < > 225 imgWidth < / imgWidth >
    < imgHeight > 300 < / imgHeight >
    < / image >
    < image >
    < imgTitle > Fresh Fruits. < / imgTitle >
    fresh_fruits.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    Fruits Apple and lawyer < imgTitle >. < / imgTitle >
    fruits_apple_avocado.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    < imgTitle > Kiwi fruit. < / imgTitle >
    kiwi_fruits.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    < imgTitle > lime fruit. < / imgTitle >
    lime_fruits.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    < imgTitle > plum fruit < / imgTitle >
    plum_fruits.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    < imgTitle > fruit Rambutan. < / imgTitle >
    rambutan_fruits.jpg < imgURL > < / imgURL >
    < / image >
    < image >
    Strawberry < imgTitle > < / imgTitle >
    Strawberry.jpg < imgURL > < / imgURL >
    < / image >
    < / fruit >

    Note: my images and xml is under the folder named "Images".

    The error that I got when I play the movie is "#2044 Error: Unhandled IOErrorEvent:.» "Text = Error #2035: URL not found."

    But when I find the code of red color above 'rawImg '.

    I got this error when I played the movie with trace function:

    dragon_fruits.jpg
    Error #2044: Unmanaged by the IOErrorEvent:. Text = Error #2035: URL not found.

    Hello

    you have all the images in the images folder

    You can change your xml like this file

    images\urimage_name.jpg

    try it

    Best wishes

    Kamal

  • splits the string into documents

    Hello

    I did a query (see regexp) that split a string into records. The problem with the query is the separate in the subquery. Otherwise, it returns millions of records where I expect less than a thousand.
    Meanwhile, I found an other solution (see xmlsequence), but this statement returns the message "ORA-03113: end of file on the communication channel.

    Please advice.

    regexp:
        SELECT smp.sample_id
        FROM
        (
            SELECT sa.sample_id, sau.u_box_code, sau.u_box_position
            FROM lims_sys.sdg sd, lims_sys.sdg_user sdu, lims_sys.sample sa, lims_sys.sample_user sau
            WHERE sd.sdg_id = sdu.sdg_id
            AND sd.sdg_id = sa.sdg_id
            AND sa.sample_id = sau.sample_id
            AND sau.u_padded_out = 'F'
            AND sdu.u_client_type =  decode('#Client#','-1',sdu.u_client_type,'#Client#')
            AND sdu.u_crop_group = decode('#Crop#','-1',sdu.u_crop_group,'#Crop#')
            AND sdu.u_year_of_sample_delivery = decode('#Year#',-1,sdu.u_year_of_sample_delivery,'#Year#')
            AND sdu.u_week_of_processing = decode('#Week#',-1,sdu.u_week_of_processing,'#Week#')
            AND sd.status IN ('V','P','C')
        ) smp,
        (
            SELECT distinct box_code, regexp_substr(box_pos,'[^,]+',1,level) box_pos 
            FROM
            (
                 SELECT p.name box_code, substr(p.description,instr(p.description, 'NP=') + 3) box_pos
                 FROM lims_sys.plate_template pt, lims_sys.plate p, lims_sys.plate_user pu
                 WHERE pt.plate_template_id = p.plate_template_id
                 AND p.plate_id = pu.plate_id
                 AND pt.name = 'Box96'
                 AND p.status IN ('V','P','C')
                 AND p.description like '%NP=%'
                 AND pu.u_client_type = decode('#Client#','-1',pu.u_client_type,'#Client#')
                 AND pu.u_crop_group = decode('#Crop#','-1',pu.u_crop_group,'#Crop#')
                 AND pu.u_year = decode('#Year#',-1,pu.u_year,'#Year#')
                 AND pu.u_week = decode('#Week#',-1,pu.u_week,'#Week#')
             )
             connect by level <= length(box_pos) - length(replace(box_pos,',')) + 1
        ) box
        WHERE smp.u_box_code = box.box_code
        AND smp.u_box_position = box.box_pos
    xmlsequence:
        SELECT smp.sample_id
        FROM
        (
            SELECT sa.sample_id, sau.u_box_code, sau.u_box_position
            FROM lims_sys.sdg sd, lims_sys.sdg_user sdu, lims_sys.sample sa, lims_sys.sample_user sau
            WHERE sd.sdg_id = sdu.sdg_id
            AND sd.sdg_id = sa.sdg_id
            AND sa.sample_id = sau.sample_id
            AND sau.u_padded_out = 'F'
            AND sdu.u_client_type =  decode('#Client#','-1',sdu.u_client_type,'#Client#')
            AND sdu.u_crop_group = decode('#Crop#','-1',sdu.u_crop_group,'#Crop#')
            AND sdu.u_year_of_sample_delivery = decode('#Year#',-1,sdu.u_year_of_sample_delivery,'#Year#')
            AND sdu.u_week_of_processing = decode('#Week#',-1,sdu.u_week_of_processing,'#Week#')
            AND sd.status IN ('V','P','C')
        ) smp,
        (
            SELECT  box_code, trim(x.column_value.extract('e/text()')) box_pos 
            FROM
            (
                 SELECT p.name box_code, substr(p.description,instr(p.description, 'NP=') + 3) box_pos
                 FROM lims_sys.plate_template pt, lims_sys.plate p, lims_sys.plate_user pu
                 WHERE pt.plate_template_id = p.plate_template_id
                 AND p.plate_id = pu.plate_id
                 AND pt.name = 'Box96'
                 AND p.status IN ('V','P','C')
                 AND p.description like '%NP=%'
                 AND pu.u_client_type = decode('#Client#','-1',pu.u_client_type,'#Client#')
                 AND pu.u_crop_group = decode('#Crop#','-1',pu.u_crop_group,'#Crop#')
                 AND pu.u_year = decode('#Year#',-1,pu.u_year,'#Year#')
                 AND pu.u_week = decode('#Week#',-1,pu.u_week,'#Week#')
             ) t, table (xmlsequence(xmltype('<e><e>' || replace(t.box_pos,',','</e><e>')|| '</e></e>').extract('e/e'))) x
        ) box
        WHERE smp.u_box_code = box.box_code

    Hello

    When 'LEVEL '.<= x"="" is="" the="" only="" connect="" by="" condition,="" then="" you="" should="" be="" using="" a="" table="" that="" has="" only="" one="" row,="" like="">

    You can generate a Table of counters (a result set, in fact) who has all the integers that you need and then join one.
    The next thread is an example:
    I don't don't want to mark in plsql

  • split a string into pl/sql

    Hello

    How to split a string and store in an associative array in pl/sql.function

    My string like this

    '1102,1101,1012,1011,1010,1009,1008,1007,1006,10005,1004,1003,1002,1001'
    and assign it to the array list. According to
    can someone please help

    concerning
    r

    You can try the following. Although I recommend, it would be better to write the function code php as a java stored procedure parser and use the result. We have a class defined in Java String Tokenizer.

    -- Define function to split string into tokens
    FUNCTION get_token(
        p_input_string IN VARCHAR2,            -- input string
        p_token_number IN PLS_INTEGER,         -- token number
        p_delimiter    IN VARCHAR2 DEFAULT ',' -- separator character
      )
      RETURN VARCHAR2
    IS
      v_temp_string VARCHAR2(32767) := p_delimiter || p_input_string ;
      v_pos1 PLS_INTEGER ;
      v_pos2 PLS_INTEGER ;
    BEGIN
      v_pos1     := INSTR( v_temp_string, p_delimiter, 1, p_token_number ) ;
      IF v_pos1   > 0 THEN
        v_pos2   := INSTR( v_temp_string, p_delimiter, 1, p_token_number + 1) ;
        IF v_pos2 = 0 THEN
          v_pos2 := LENGTH( v_temp_string ) + 1 ;
        END IF ;
        RETURN( SUBSTR( v_temp_string, v_pos1+1, v_pos2 - v_pos1-1 ) ) ;
      ELSE
        RETURN NULL ;
      END IF ;
    EXCEPTION
      WHEN OTHERS THEN
        RAISE;
    END get_token;
    
    -- Call the above function in loop for a string with N tokens
    DECLARE
          TYPE assoc_arr_str_typ IS TABLE OF VARCHAR2(100) INDEX BY PLS_INTEGER;
          str_arr assoc_arr_str_typ;
    
          v_str VARCHAR2(200) := '1102,1101,1012,1011,1010,1009,1008,1007,1006,10005,1004,1003,1002,1001' ;
          v_token   VARCHAR2(4) ;
          i          PLS_INTEGER := 1 ;
        BEGIN
          LOOP
            v_token := get_token( v_str, i , ',') ;
            EXIT WHEN v_token IS NULL ;
            dbms_output.put_line( v_token ) ;
            str_arr(i) := v_token;
            i := i + 1 ;
         END LOOP ;
      END ;
     /
    

    Published by: GG 24 March 2011 09:51

  • SQL / PLSQL to split the string into pieces

    Hi all

    I have a problem of data conversion from the name of one table to another structure.

    for example

    SQL > desc names
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    TITLE VARCHAR2 (5)
    FNAME VARCHAR2 (20)
    LNAME VARCHAR2 (20)

    SQL > Data desc
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    FULLNAME VARCHAR2 (50)


    Insert in data values ("SIR I HAVE ONE NAME PARTICULARLY LONG INDEED");
    Insert in the data values ("MINE IS EVEN MORE, ENOUGH RIDICULEMENT so IN FACT");

    Essentially, I need to divide these names long, stored in the 1 field, in the above 3 fields. The trickiest part is however I want to do it in such a way so that if the 1st part of the name fits the 1 5 char field I want to do, otherwise I would divide between 2 fields - once again without splitting a string. The reason behind this is that application will automatically put a space between each field when they appear and I would avoid gaps in the names if possible.

    This baffled me a little if any help would be seriously great... it might not even be a go-er, as it might be too uneconomic with the amount of available space, but I would give it a shot.

    Thank you!
    Adam

    Hi, Adam.

    Use regular expressions:

    INSERT INTO names (title, fname, lname)
    SELECT  RTRIM (REGEXP_SUBSTR ( fullname
                              , '^.{1,5} '
                        )
               )
    ,     REGEXP_REPLACE ( fullname
                     , '(^.{1,5} )?'       ||     -- \1      = optional 1-5-letter word(s)
                           '(.{1,20})'       ||     -- \2       = 1-20 letters
                    '(( .*)|$)'          -- \3-\4 = space (plus anything) or end
                     , '\2'
                     )
    ,     REGEXP_REPLACE ( fullname
                     , '(^.{1,5} )?'       ||     -- \1      = optional 1-5-letter word(s)
                           '(.{1,20}( |$))' ||     -- \2-\3 = 1-20 letters and space or end
                           '(.{1,20})?'       ||     -- \4       = 0-20 letters
                    '(( .*)|$)'          -- \5       = space (plus anything) or end
                     , '\4'
                     )
    FROM     data_table          -- data is not a good name
    ;
    

    Published by: Frank Kulash, August 18, 2009 11:13
    Revised to manage long single word fullname

  • How can I remove the split screen option when you open an attachment on the email?

    I had used the option of screen split using strong control of the two tabs on the toolbar at the bottom of the screen and right click for the split-screen option.  Now, when I open an application such as Internet explorer, it happens in the split screen mode.  This is quite annoying and I would like to know how to restore everything in full screen when opening applications, web pages, etc.

    Thank you.

    Hi ClaudiamYE,

    In addition to querry of Samhruth G, please let us know what happens if you click on optimize your internet explore or any application, you get full-screen this time?

    As your subject what I understand you face split screen problem when opening word document in e-mail, so it is called reading pane. You can disable it from within Word, click on start-> all programs-> Word 07-> click the Ribbon on the upper left-> select the Word Options-> Popular => uncheck «attachments open in full screen...» ».

    I hope this helps.

  • There are two screens (split screen) showing when the computer is turned on.

    There are two screens (split screen) showing when the computer is turned on. How can I delete one side to return to a view?

    Hi Ikthomas1,

    When did you start in this topic? Were there recent changes to the computer like installing new hardware, software or updates? If it is a recent issue, follow the steps in this document to perform a System Restore. This will restore your comuter up to a point located before the show.

    If you have antivirus software installed, run a scan of filling. You can also use Microsoft Security Essentials to scan your computer.

  • Oracle regular expressions - splits the string into words for

    Hello

    Nice day!

    My requirement is to split the string into words.

    So I need to identify the new line character and the semicolon (;), comma and space like terminator for string entry.

    Please note that I am currently embedded blank and the comma as separator, as shown below.

    Select regexp_substr('test)
    TO
    string in words, "([^, [: blanc:]] +) (', 1, 1) double;"

    How to integrate the semicolons and line break characters in regular expression Oracle?

    Please notify.

    Thanks and greetings

    Sree

    This has nothing to do with REGEXP. Is SQL * more parser does not not a semicolon at the end of the line:

    SQL > select ' testto, mm\;
    ERROR:
    ORA-01756: city not properly finished chain

    SQL >

    Just break the chain:

    SQL > select regexp_substr ('testto, mm\;' |) '
    2 string into words
    3 \w+',1,level ',') of double
    4. connect by level<= regexp_count('testto,mm\;'="" ||="">
    5 string in words
    6      ','\w+')
    7.

    REGEXP_SUBSTR ('TESTTO, MM\;' |') STRINGIN
    --------------------------------------
    Testto
    mm
    string
    in
    Words

    SQL >

    Or modify SQL * more the character of endpoints:

    SQL > set sqlterm.
    SQL > select regexp_substr ('testto, mm\;)
    2 string into words
    3 \w+',1,level ',') of double
    4. connect by level<=>
    5 string in words
    6      ','\w+')
    7.

    REGEXP_SUBSTR ('TESTTO, MM\;) STRINGINTOWO
    --------------------------------------
    Testto
    mm
    string
    in
    Words

    SQL >

    SY.

  • How to split a string into several substrings parent using a delimiter

    Hello

    I am forced to split a string into several substrings parent using a delimiter.

    And insert these substrings in variuou of the columns of a table in a row.

    For example. The sting is: ABC * DEF * GHI * JKH *.

    where ' *' is the separator.

    Desired output:

    Col1 Col2 Col3 Col4 Col5

    -------     --------     --------     -------     ---------

    JKH GHI ABC DEF (null)

    Could you please guide me how can I achieve this.

    Thank you

    Bogoss

    Hello Salim,

    Leave the thread for reference... got this excerpt:

    with t as

    (

    Select "c: its: hgfd:1:23" Str

    )

    Select

    REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 1, null, 1) col1

    , REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 2, null, 1) col2

    , REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 3, null, 1) col3

    , REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 4, null, 1) col4

    , REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 5, null, 1) col5

    t;

    This code snippet works well, but for the fixed columns. Here are 5 predefined columns.

    But I need to have a logic that I can browse the string any No.. sometimes.

    For example. If I get 3 secondary channels of the parent chain... I need to insert into 3 columns.

    And if I get 6 strings under... I need to insert into 6 columns.

    Could you please help me develop a logic like that.

    I use Oracle database 10g.

    And the data are currently being collected on external table... but I can store in a variable or a column of a database table.

    Thank you

    Bogoss

  • splits the string into 3 parts

    Hello

    I have a requirement to split the string into 3 different room example inf.ethz.ch should be subdivided into inf ethz ch in 3 different column

    We have table called email within this column contains all identification of email we need to divide email with dot (.) in different columns and display please suggest how to implement in the query

    Thank you

    Sudhir

    Use REGEXP_SUBSTR:

    SQL > with t as (select ' inf.ethz.ch' double txt)
    2 Select regexp_substr (txt,'[^.] +') part_1,.
    3 regexp_substr (txt,'[^.] +', 1, 2) part_2,.
    4 regexp_substr (txt,'[^.] +' 1, 3) part_3
    5 t
    6.

    BY PARTY PA
    --- ---- --
    INF ethz ch

    SQL >

    Or you can use SUBSTR + Instr.

    SY.

  • How to use several query string in a URL?

    Can someone help me with the use of more than a query string in a URL?  I would like to pass on the details of the campaignID (for the CLR) and industry (redirect after form submission) with a click of an email to a landing page.

    Thank you very much

    Alan,

    There are two posts really great on this topic that should help you get there quite easily.

    First, take a look at the position of glreichertof EE12. EE12 - Do-It - Thomson Reuters - Super power of blind forms

    Then visit chorenfto post on the blind forms. Eloqua10: trigger multiple actions with a click-through email (via 'send blind form')

    I have these two positions of reference whenever I need an update on query strings and always answers my questions.

    Good luck.

    Krista

  • Split a string using regexp_substr with consecutive delimiter

    I split a string with tubes as a delimiter. A string like this for example:

    "THIS |" EAST | ONE | EXAMPLE '

    If I do something like this:

    SELECT REGEXP_SUBSTR('THIS|IS|AN|EXAMPLE', '[^|]+', 1, 4) FROM DUAL
    

    I would get the word EXAMPLE

    But if the string is like this:

    "THIS |" EAST | ONE | EXAMPLE '

    With the above query, I always get EXAMPLE, but the word should be in the next position (5) because after IS, there should be an empty element

    Is it possible to change the regular expression to also get the empty element?

    Thanks in advance

    Well, the way I understand it, you get this behavior, because there is 'nothing' between the delimiters. so there is a field, so it does not display it don't think the regular expression.

    Try it with a space between the delimiters - works fine.

    So, with this in mind, the simplest solution might be something like that?

    regexp_substr (replace(c,'||','| |'), "[^ |]") +' 1, 4)

    [edited to avoid having a partial answer marked "correct"]

    As mentioned below by a few others, there are other solutions using regular expressions.

    The solution above does not work if more than 2 consecutive fields are empty, or if the first or last is empty.

    A simple tweak to the logic would help with this:

    RTrim (regexp_substr (replace (c,'|))) ',' |'), ' [^ |] +', 1, level))

    However, even if it has still some limitations compared to the solution of the full regular expression mentioned by Frank, below.

    [/ Edit]

  • I realized that I had a message to update for a while then when I checked, I found that the app CC was missing. I downloaded and installed the application, but it will not update of software. In the creative cloud Panel, the only options I get are the Hom

    I realized that I had a message to update for a while then when I checked, I found that the app CC was missing. I downloaded and installed the application, but it will not update of software. In the creative cloud Panel, the only options I get are the Home tab to check the activity and the Stock tab. The applications tab is missing. How can I get that back so I can update photoshop and lightroom?

    Please, try the steps mentioned here https://helpx.adobe.com/creative-cloud/kb/apps-panel-reflect-creative-cloud.html

    Let me know if it works!

Maybe you are looking for