Solved

Reg Ex help

Posted on 2013-01-15
6
187 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
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:Wayne Atherton
Comment Utility
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 74

Assisted Solution

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

Author Closing Comment

by:Wayne Atherton
Comment Utility
cheers
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now