PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 [RESOLVED] Regex.Replace - wildcard (Noob question)-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] Regex.Replace - wildcard (Noob question)

  1. #1

    Thread Starter
    Member intellilogic's Avatar
    Join Date
    Oct 2010
    Location
    Tyson's Corner, VA
    Posts
    39

    Resolved [RESOLVED] Regex.Replace - wildcard (Noob question)

    Desired result in improper form
    X = Regex.Replace(X, ""*"", "")

    I want to replace everything between those 2 characters.

    I actually want to strip it all out. 43398475-4375 becomes: 398475-4375

    All the characters between those tags happen to be numeric, but I'd prefer something that just stripped anything and everything between them.

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Regex.Replace - wildcard (Noob question)

    The pattern regex should be
    Code:
    §.*§(.+)
    The replace expression should be
    Code:
    $1

  3. #3

    Thread Starter
    Member intellilogic's Avatar
    Join Date
    Oct 2010
    Location
    Tyson's Corner, VA
    Posts
    39

    Re: Regex.Replace - wildcard (Noob question)

    I don't really know what I am doing here, I am not much of a programmer. But I am getting an error on the character §. Do I need quotes somewhere?
    Stripped = system.text.regularexpressions.regex.replace(txtSkuIntake.Text, §.*§(.+), $1)

  4. #4
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Regex.Replace - wildcard (Noob question)

    Yes, put both expressions in double quotes.

    Code:
    Stripped = system.text.regularexpressions.regex.replace(txtSkuIntake.Text, "§.*§(.+)", "$1")

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,836

    Re: Regex.Replace - wildcard (Noob question)

    vb Code:
    1. txtSkuIntake.Text = regex.replace(txtSkuIntake.Text, "§.*§", "")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width