+ Reply to Thread
Results 1 to 8 of 8

Regular Expression Pattern All Letters In String

  1. #1
    Forum Contributor
    Join Date
    01-07-2004
    Posts
    314

    Regular Expression Pattern All Letters In String

    Hi all,

    Using Excel 2013.

    Trying to get the pattern to return all letters in a string
    My test string is "asdf134!#@$adsf]"
    My current pattern is "[a-zA-Z]*"
    So the result should be "asdfadsf"
    But my pattern stops when 1 is encountered so the output is "asdf"

    How can I get the pattern to continue through the entire string?

    thx
    w

    Sub:
    Please Login or Register  to view this content.
    Function
    Please Login or Register  to view this content.
    Kind regards,
    w

    http://dataprose.org

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Regular Expression Pattern All Letters In String

    Hi goss,
    try it
    Please Login or Register  to view this content.
    (I forgot the name link to the Regexp in the available references)
    Last edited by nilem; 08-04-2013 at 01:20 PM.

  3. #3
    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: Regular Expression Pattern All Letters In String

    How about ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    01-07-2004
    Posts
    314

    Re: Regular Expression Pattern All Letters In String

    Nilem / Shg,

    Thanks.
    Nice use of recursion - the function works great!

    Do you know is there a class for letters only.
    I've Google'd quite a bit haven't found anything.

    thx
    w

  5. #5
    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: Regular Expression Pattern All Letters In String

    There's no recursion in those functions.

    "[A-Za-z]" is the pattern for letters, or just "[A-Z]" if ignoring case.

  6. #6
    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: Regular Expression Pattern All Letters In String

    I would combine nilems's late-binding approach (to avoid the need for a reference) with a static object variable for speed:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-07-2004
    Posts
    314

    Re: Regular Expression Pattern All Letters In String

    Thanks shg,

    Now I understand.
    I was trying to extract only letters
    You are replacing if not a letter with nothing.

    Genius, thanks!
    w

  8. #8
    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: Regular Expression Pattern All Letters In String

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Regular Expression Pattern May Include Decimal
    By goss in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2013, 02:15 PM
  2. regular expression to extract multi instances of pattern from cell
    By starfish_001 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2013, 07:45 PM
  3. [SOLVED] Find a string by VBA Regular Expression and replace a part of that string
    By taps in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2013, 11:08 AM
  4. Regular Expression Pattern Testing Add-In
    By Firefly2012 in forum The Water Cooler
    Replies: 1
    Last Post: 02-19-2012, 06:52 PM
  5. Using a regular expression to pull out data from a string
    By mundo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-12-2008, 07:42 AM

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