Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:01:31+00:00 2026-06-12T01:01:31+00:00

I have a function pulled from here . My problem is that I don’t

  • 0

I have a function pulled from here. My problem is that I don’t know what RegEx pattern I need to use to split out the following data:

+1 vorpal unholy longsword +31/+26/+21/+16 (2d6+13)
+1 vorpal flaming whip +30/+25/+20 (1d4+7 plus 1d6 fire and entangle)
2 slams +31 (1d10+12)

I want it to look like:

+1 vorpal unholy longsword, 31 
+1 vorpal flaming whip, 30 
2 slams, 31

Here is the VBA code that does the RegExp validation:

Public Function RXGET(ByRef find_pattern As Variant, _
                        ByRef within_text As Variant, _
                        Optional ByVal submatch As Long = 0, _
                        Optional ByVal start_num As Long = 0, _
                        Optional ByVal case_sensitive As Boolean = True) As Variant
' RXGET - Looks for a match for regular expression pattern find_pattern
' in the string within_text and returns it if found, error otherwise.
' Optional long submatch may be used to return the corresponding submatch
' if specified - otherwise the entire match is returned.
' Optional long start_num specifies the number of the character to start
' searching for in within_text. Default=0.
' Optional boolean case_sensitive makes the regex pattern case sensitive
' if true, insensitive otherwise. Default=true.

Dim objRegex As VBScript_RegExp_55.RegExp
Dim colMatch As VBScript_RegExp_55.MatchCollection
Dim vbsMatch As VBScript_RegExp_55.Match
Dim colSubMatch As VBScript_RegExp_55.SubMatches
Dim sMatchString As String

Set objRegex = New VBScript_RegExp_55.RegExp

' Initialise Regex object
With objRegex
    .Global = False
    ' Default is case sensitive
    If case_sensitive Then
        .IgnoreCase = False
    Else: .IgnoreCase = True
    End If
    .pattern = find_pattern
End With

' Return out of bounds error
If start_num >= Len(within_text) Then
    RXGET = CVErr(xlErrNum)
    Exit Function
End If
sMatchString = Right$(within_text, Len(within_text) - start_num)

' Create Match collection
Set colMatch = objRegex.Execute(sMatchString)
If colMatch.Count = 0 Then ' No match
    RXGET = CVErr(xlErrNA)
Else
    Set vbsMatch = colMatch(0)
    If submatch = 0 Then ' Return match value
        RXGET = vbsMatch.Value
    Else
        Set colSubMatch = vbsMatch.SubMatches ' Use the submatch collection
        If colSubMatch.Count < submatch Then
            RXGET = CVErr(xlErrNum)
        Else
            RXGET = CStr(colSubMatch(submatch - 1))
        End If
    End If
End If
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:01:33+00:00Added an answer on June 12, 2026 at 1:01 am

    I don’t know about Excel but this should get you started on the RegEx:

    /(?:^|, |and |or )(\+?\d?\s?[^\+]*?) (?:\+|-)(\d+)/
    

    NOTE: There is a slight caveat here. This will also match if an element begins with + only (not being followed by a digit).

    Capture groups 1 and 2 contain the strings that go left and right of your comma (if the whole pattern has index 0). So you can something like capture[1] + ', ' + capture[2] (whatever your syntax for that is).

    Here is an explanation of the regex:

    /(?:^|, |and |or )         # make sure that we only start looking after
                               # the beginning of the string, after a comma, after an
                               # and or after an or; the "?:" makes sure that this
                               # subpattern is not capturing
     (\+?                      # a literal "+"
     \d+                       # at least one digit
                               # a literal space
     [^+]*?)                   # arbitrarily many non-plus characters; the ? makes it
                               # non-greedy, otherwise it might span multiple lines
                               # a literal space
     \+                        # a literal "+"
     (\d+)/                    # at least one digit (and the brakets are for capturing)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that loops through different types of listings pulled from MySQL
So I have a function that I've pulled from a tutorial: let sumOfSquares nums
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
I have a list of images that are pulled from a database and loaded
I have a list of items that is dynamically pulled from a web service.
I have pages of data, pulled from a database. I need to be able
I have function getCartItems in cart.js and I want to call that function in
I have function Start() that is fired on ready. When I click on .ExampleClick
i have function to send mail with attachment to microsoft exchange server. My problem
Inside my Controller i have function that runs after user clicks on item, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.