+ Reply to Thread
Results 1 to 3 of 3

RexEx to extract from middle or end of string

  1. #1
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86

    RexEx to extract from middle or end of string

    Hey,

    This is probably very simple but am having a mind block and am quite new to RegExs. I need to extract a string Starting EMI followed by a combination of numbers and/or letters from a string. Probably easiest to explain with examples:

    1: String: _01_00_001_PART_ASSEMBLY_EMI1234 Retrieve: EMI1234
    2: String: _01_00_001_PART_EMI7882_SP1801387 Retrieve EMI7882
    3: String: DDR_SP1801387_01_00_001_PART_EMI3404A Retrieve:EMI3404A
    4: String: 01_00_001_PART_EMI7882CD_SP1801387 Retrieve: EMI7882CD

    The "EMI" will only ever occur once in the string, basically I want to extract everything following the EMI up until the next underscore or the end of the string.

  2. #2
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86
    No worries, I think I have it:

    The pattern EMI[A-Za-z0-9]*

    Seems to work

    By the way, I found this site through a search of other forums and it's a very good site for testing RegExs, I thought it could be useful to people.

    http://www.regexlib.com/RETester.aspx

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Thanks for posting your solution, and the link. It does indeed look useful, I've bookmarked it.

+ 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