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 8812951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:43:26+00:00 2026-06-14T03:43:26+00:00

New to Powershell/Regex/EDI. Please no comments on why this shouldn’t be done with regular

  • 0

New to Powershell/Regex/EDI. Please no comments on why this shouldn’t be done with regular expressions for EDI, I’ve seen the warnings, but have no choice.

What I need is most likely basic, but I need some help. I have to find all instances of a segment, and retrieve a specific element value from it. The text being searched will be read as one long string, with no CR/LF/etc.

Example data:

~SV1*HC:V2020*35*UN*1***1~DTP*472*D8*20120807~REF*6R*
~SV1*HC:V2100:LT*28.98*UN*1***1~DTP*472*D8*20120807~REF*6R*
~SV1*HC:92014*165*UN*1***1~DTP*472*D8*20120716~REF*6R*

I’m using the following command on another segment and it works just like i want, but it doesn’t have to account for non-word characters either:

Select-String -pattern '~svd\*\w+\*(\d+|\d+\.\d+)\*' -input $string -AllMatches | %{$_.Matches} | %{$_.Groups[1]} | %{$_.Value}

Ideally, I would like to find an instance of “~SV1*”, skip to the next asterisk, then read everything through the next asterisk. That way it doesn’t matter what letter/number/character is in there, it skips it. In the data example above, I would want a return of 35, 28.98, 165. If not, then I can work with what I have, but matching on combinations of word/non-word characters is throwing me, since I don’t know what order they may exist in. Everything else I’ve played with has continued on pulling the rest of the string, and not stopping properly.

If I can get it to do this, I’d be very happy:

~SV1*<skip this>*<get this>*<skip to next SV1>~SV1*<skip this>*<get this>*<skip to next SV1>

Lastly, the data being pulled is a money field, so it may or may not have a decimal present. If there is a cleaner way than (\d+|\d+.\d+), I’m all for it.

Thanks

  • 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-14T03:43:28+00:00Added an answer on June 14, 2026 at 3:43 am

    Use a pattern like this:

     ~sv\d\*[^*]*\*([^*]*)\*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a simple question, but I am new to PowerShell and could
I am new in powershell but was wondering how do you get combination of
I'm fairly new to PowerShell, but have a strong C# background. The task I'm
In Powershell I am defining a new PSDrive called test . But when I
I'm new to powershell, but I'm trying to output some simple logging in a
I'm new to powershell, but I'm trying to output some simple logging in a
Im new to powershell - so serious noob. But I wanted to see if
I'm new to powershell and this question will prove that point. I'm trying a
I'm new to powershell. What does this structure mean in powershell: ${c:a.txt} Thanks.
Hi I'm completely new to Powershell so pardon me if this question has a

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.