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

  • Home
  • SEARCH
  • 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 4087454
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:51:27+00:00 2026-05-20T18:51:27+00:00

I need help to parse some information from a mass of text, basically I

  • 0

I need help to parse some information from a mass of text, basically I am importing a PSD file and want to parse some data from it.

Amongst the text are strings such as this:

\r\nj78876 RANDOM TEXT STRINGS 75 £

Now what I want to do is grab all strings that fit this format (maybe the starting “\r\n” and ending “£” can be delimiters) and get the code at the start (j78876) and the price at the end (75). Note price may be more digits that 2.

I want to then grab the code such as j78876 and the price for each string like this which is found as they will occur many times (different codes and prices).

Can anyone suggest a way to do this?

I am not very proficient with Regex so guidance would be great.

thanks.

Note: Here is a snipped of the actual text (there is a lot more in the actual file).

Référence Ancienne référence 3Com/H3C Libellé Remarque Prix en €\r\nJ9449A HP V1810-8G
Switch 139,00\r\nJ9450A HP V1810-24G Switch 359,00\r\nEdge Switches – Managed \r\nHP Layer
2 Switches – Managed Stackables and Chassis\r\nHP Switch 2510 Series\r\nRéférence Ancienne
référence 3Com/H3C Libellé Remarque Prix en €\r\nJ9019B HP E2510-24 Switch 359,00\r
\nJ9020A HP E2510-48 Switch 599,00\r\nJ9279A HP E2510-24G Switch 779,00\r\nJ9280A HP
E2510-48G Switch 1 569,00\r\nHP Switch 2520 Series\r\nRéférence Ancienne référence
3Com/H3C Libellé Remarque Prix en €\r\nJ9137A HP E2520-8-PoE Switch 489,00\r\nJ9138A HP
E2520-24-PoE Switch 779,00\r\nJ9298A HP E2520-8G-PoE Switch 749,00\r\nJ9299A HP E2520-
24G-PoE Switch 1 569,00\r\nHP Layer 2 and 3 Switches – Managed Stackables and Chassis\r
\nThe RBP is a recommended price only. \r\nHP Switch 2600 Series\r\nRéférence Ancienne

Update
I found this:

[\\r\\n](\w\d+\w).*?(\d+,\d\d)[\\r\\n]

Worked for me in regex browser testers but will not work in my C# code

Regex reg = new Regex(@"[\\r\\n](\w\d+\w).*?(\d+,\d\d)[\\r\\n]", RegexOptions.IgnoreCase);
Match matched = reg.Match(str);
if (matched.Success)
{
    string code = matched.Groups[1].Value;
    string currencyAmt = matched.Groups[2].Value;
}

Final Update:
In the browser testers i had to double escape the \r\n – in my code it was not necessary. Then to loop the groups I used the looping answer.

foreach (Match match in Regex.Matches(content, @"[\r\n](?<code>\w\d+\w).*?(?<price>\d+,\d\d)[\r\n]", RegexOptions.IgnoreCase))
{
    string code = match.Groups["code"].Value;
    string currencyAmt = match.Groups["price"].Value;
}
  • 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-05-20T18:51:27+00:00Added an answer on May 20, 2026 at 6:51 pm

    I would use named groups to identify the groups easier. The ?<code> part of the expression identifies the group.

    You will want to use Matches, as you say there will be several occurrences of the pattern in your text. This will loop through them all..

    foreach ( Match match in Regex.Matches(text, @"\r\n(?<code>\S+).*?(?<price>\d+)£") )
    {
        string code = match.Groups["code"].Value;
        string currencyAmt = match.Groups["price"].Value;
        Console.WriteLine(code);
        Console.WriteLine(currencyAmt);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help parsing out some text from a page with lxml. I tried
I'm currently working with parsing some data from SQL Server and I'm in need
I need help understanding some C++ operator overload statements. The class is declared like
A file name will be passed in from standard in. I want to open
I am using some XML parser to get some information from API, blah blah...
Greetings everyone, going to need some help in clearing this exception. I get the
I am trying to parse some xml data by passing the variables with a
I am trying to parse some text files into a database and there is
I'm a student and I got a homework i need some minor help with
I need some help figuring out why the following scenario does not work. I'm

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.