Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Url search

I am programming a forum, and have a wall. I would like to check if a paragraph of text has a url with in it. Then surround that url with a link tag. For example:


http://www.urlhere.com



would then become


http://www.urlhere.com


Boycey


Comments

  • I am assuming you have already got the paragraph into

    a scalar variable.


    $bufftext = $paragraph;


    # Get rid of


    chomp($bufftext);


    # Split words at spaces

    @words = split(" ", $bufftext);


    # Skim through words looking for URLS


    foreach $word (@words) {

    # if word is url format

    if($word =~ /http://.*..*/) {

    print "$word";

    }

    else {

    print "$word";

    }


    Hope this helps,

    Matt(AA)


    : I am programming a forum, and have a wall. I would like to check if a paragraph of text has a url with in it. Then surround that url with a link tag. For example:


    : http://www.urlhere.com

    :

    : would then become


    : http://www.urlhere.com


    : Boycey





  • Justin BibJustin Bib USAMember Posts: 0

    ___ [ http://forcoder.org ] free ebooks and video tutorials about | C, C++, Java, Swift, Perl, Go, PL/SQL, Scratch, Ruby, R, C#, Delphi, Assembly, Visual Basic, Objective-C, PHP, Python, Visual Basic .NET, MATLAB, JavaScript Logo, VBScript, COBOL, Rust, LabVIEW, Hack, Erlang, Scheme, Dart, Awk, Ada, F#, Prolog, FoxPro, Clojure, Julia, Alice, Crystal, Scala, Transact-SQL, SAS, Kotlin, D, Apex, ML, ABAP, Lua, Bash, Fortran, Lisp | ____

Sign In or Register to comment.