?
Solved

Reg Ex help

Posted on 2013-01-15
6
Medium Priority
?
193 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 2000 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

777 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