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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:27:35+00:00 2026-06-01T12:27:35+00:00

I’m opening a file and finding the line I need, but then I have

  • 0

I’m opening a file and finding the line I need, but then I have trouble creating a variable from the found string

70c 08:04:04.014    rexx    TRACE   2203 8=4.4|9=892|35=J|49=ICE_SM_S|56=SM|34=280|70=0241608914160889|71=0|626=2|793=16|72=|466=1164266784|857=0|73=1|11=|37=1156426784|526=1156426674|38=1|198=1310883PTM|54=1|6=117.2100000000|336=R|625=P|55=B|461=FXXXXX|200=20120901|207=IFEU|53=1|30=ICE|453=2|448=SLM|447=C|452=7|448=FFC|447=C|452=12|75=20120210|60=20120310-09:04:04|77=O|58=CYU795|232=14|233=GL_TRADEJOBOUT|234=N|233=GL_ORDERJOBOUT|234=N|233=GL_TAKEN|234=0|233=GL_TRADETYPE|234=E|

This is the string and I want to assign it to a variable of tag198, so it would be

tag198 = '1310883PTMS'

Anything after | is not needed.

tag198 = line.match(/198=(.*)/)[1]
puts tag198

but that keeps all after 198; I need just the string prior to the |.

  • 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-01T12:27:36+00:00Added an answer on June 1, 2026 at 12:27 pm

    Your regular expression’s * is greedy, and will consume all characters it can without stopping the rest of the expression from matching. There is nothing in the expression that tells ruby when to stop collecting characters.

    Look at regular-expressions.info. A partial fix for your problem would be to put a ‘|’ after your capture:

    tag198=line.match(/198=(.*)\|/)[1] puts tag198

    The ‘|’ is escaped as it has special meaning in regexes otherwise. This doesn’t yet work though, because the * can still consume ‘|’ characters, so long as it leaves one behind to match the ‘|’ in our expression. To fix completely, prevent the * from capturing any pipes:

    tag198 = line.match(/198=([^|]*)\|/)[1] puts tag198

    See results of this change here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from

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.