Solved

Reg Ex help

Posted on 2013-01-15
6
191 Views
Last Modified: 2013-01-15
Hi there,

need to pull some text out of hte following string:

{1:F01ABCDEFGHAXXX0000000000}{2:I101HSBFREDXXXXN}{4:|13||10|

Basically, I need to return the 8th character for a length of 11 whenever there is {2:

So for example:

from the above string i need to return HSBFREDXXXX
0
Comment
Question by:Wayne Atherton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38777999
Depending on what language you are using, you might be able to use:

(?<=\{2:.{4}).{11}

Open in new window


...though, I honestly don't think you need a regex for this task.
0
 
LVL 1

Author Comment

by:Wayne Atherton
ID: 38778011
hi kaufmed,

I am using VBScript.

I need the regex, because the value isn't always in the same place, so i need to find it based on {2:
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38778069
because the value isn't always in the same place, so i need to find it based on {2:
Still don't think you need a regex  ; )

targetString = "{1:F01ABCDEFGHAXXX0000000000}{2:I101HSBFREDXXXXN}{4:|13||10|"
sentinel = "{2:"
startOf = InStr(targetString, sentinel)

If startOf > 0 Then
    toFind = Mid(targetString, startOf + 7, 11)
End If

MsgBox toFind

Open in new window

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:Wayne Atherton
ID: 38778130
i've put this into a Function, and pass the string and sentinal in as params, but it returns nothing

strIn = Objects("InputString").text
strTy = Objects("SearchString").text

 Function MTMessage(strIn,strTy)

    startOf = InStr(strIn, strTy)

    If startOf > 0 Then
    strTy = Mid(strIn, startOf + 7, 11)
    End If

 End Function
   Objects("OutputString").text = MTMessage(strIn,strTy)
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 38778237
You're not returning anything from the function.
0
 
LVL 1

Author Closing Comment

by:Wayne Atherton
ID: 38778483
cheers
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question