+ Reply to Thread
Results 1 to 4 of 4

Wildcards with Replace()

  1. #1
    Registered User
    Join Date
    03-22-2009
    Location
    Antwerp
    MS-Off Ver
    Excel 2002 SP2
    Posts
    45

    Wildcards with Replace()

    I can't seem to find out how to use wildcards like "?" and "*" in the VBA-code: Replace("string","s*r","k") which should give "king"

    Anyone?
    Thanks.
    Last edited by onidarbe; 03-29-2009 at 05:26 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: Wildcards with Replace()

    You can't use wildcards like that with Replace. You'd need to use regular expressions.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-22-2009
    Location
    Antwerp
    MS-Off Ver
    Excel 2002 SP2
    Posts
    45

    Re: Wildcards with Replace()

    Thanks, but is * also not used in regular expressions?
    It seems regular expressions ain't working also!
    These examples till give "testing" ???!
    MsgBox Replace("testing", "s[tr]i", "")
    MsgBox Replace("testing", "s/mi", "")

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards with Replace()

    Replace doesn't support regular expressions.

    See, for example, http://msdn.microsoft.com/en-us/library/ms974570.aspx

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1