help with string replace - for doing selective replace

Discussion in 'Javascript' started by Prasad S, Aug 20, 2004.

  1. Prasad S

    Prasad S Guest

    Hello

    I wish to replace all the characters in a string except those which
    are inside '<' & '>' characters. And there could be multiple
    occurences of < & > within the string.

    e.g. string = "this is an example of <how> many words could be hidden
    <under> these characters"

    now, from this string all the characters should be searched & replaced
    by a certain logic except <how> & <under>

    I am accepting the string from a textarea form field and there can be
    no or multiple occurences of words within < >

    Any help will be highly appreciated.
    Prasad S, Aug 20, 2004
    #1
    1. Advertising

  2. Prasad S

    Evertjan. Guest

    Prasad S wrote on 20 aug 2004 in comp.lang.javascript:

    > I wish to replace all the characters in a string except those which
    > are inside '<' & '>' characters. And there could be multiple
    > occurences of < & > within the string.
    >
    > e.g. string = "this is an example of <how> many words could be hidden
    > <under> these characters"
    >


    s = "an example of <how> words <under> these characters"

    s = s.replace(/[^<]*(<[^>]*>)[^<]*/g,'$1')


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 20, 2004
    #2
    1. Advertising

  3. JRS: In article <>,
    dated Fri, 20 Aug 2004 06:12:36, seen in news:comp.lang.javascript,
    Prasad S <> posted :
    >
    >I wish to replace all the characters in a string except those which
    >are inside '<' & '>' characters. And there could be multiple
    >occurences of < & > within the string.


    Can the string be of the form " x < y < z > a > ? ", If so, some record
    of depth-of-quote is called for.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr John Stockton, Aug 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bobby Maul
    Replies:
    2
    Views:
    461
    Eddie Dodd
    May 27, 2004
  2. =?Utf-8?B?TGlsbGlhbg==?=

    Selective DataGrid

    =?Utf-8?B?TGlsbGlhbg==?=, Jun 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    356
    Marina
    Jun 2, 2004
  3. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    selective validation on specific buttons only

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Mar 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    398
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Mar 22, 2005
  4. =?Utf-8?B?U29saXR1cw==?=

    Selective databinding

    =?Utf-8?B?U29saXR1cw==?=, Oct 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    393
    Karl Seguin
    Oct 10, 2005
  5. yasaswi

    selective page access

    yasaswi, Feb 3, 2005, in forum: Java
    Replies:
    2
    Views:
    314
    yasaswi
    Feb 4, 2005
Loading...

Share This Page