473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to parse and block of text with no common delimiter?

nine72
21
I have a single data block (encrypted) that is being generated (see example block below). My issue is that there is NO delimiter in the block that I can use as a landmark to break this into only the portions that I need.

Looking at the sample at the bottom of this lets say I need to count from the left 18 places and then pull out the characters 19 to 51 and set as a value. Then move two more places to 53 and pull out 53 to 112 and make that another value etc.

I have looked at explode and some length options but nothing seams to be what I need. Any help or advice would be great (I know it can be done in perl and I have it done but I need to really do it in PHP as well.)

SAMPLE DATA BLOCK

F252A343236362A2A2A2A2A2A2A2A393939395E42555348204 A522F47454F52474520572E4D525E2A2A2A2A2A2A2A2A2A2A2 A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A3F2A3B343 236362A2A2A2A2A2A2A2A393939393D2A2A2A2A2A2A2A2A2A2 A2A2A2A2A2A3F2ADA7F2A52BD3F6DD8B96C50FC39C7E6AF22F 06ED1F033BE0FB23D6BD33DC5A1F808512F7AE18D47A60CC3F 4559B1B093563BE7E07459072ABF8FAAB5338C6CC8815FF877 97AE3A7BEAB3B10A3FBC230FBFB941FAC9E82649981AE79F26 32156E775A06AEDAFAF6F0A184318C5209E55AD44A9CCF6A78 AC240F791B63284E15B4019102BA6C505814B585816CA3C2D2 F42A99B1B9773EF1B116E005B7CD8681860D174E6AD316A0EC DBC687115FC89360AEE7E430140A7B791589CCAADB6D6872B7 8433C3A25DA9DDAE83F12FEFAB530CE405B701131D2FBAAD97 0248A456000933418AC88F65E1DB7ED4D10973F99DFC8463FF 6DF113B6226C4898A9D355057ECAF11A5598F02CA31688861C 157C1CE2E0F72CE0F3BB598A614EAABB162994901190000000 00206E203029801803F48236B
May 28 '14 #1

✓ answered by Luuk

Because substr start counting from 0, untested:
Expand|Select|Wrap|Line Numbers
  1. $a = substr($data, 19-1, 51-19+1);
  2. $b = substr($data, 53-1, 112-53+1);
  3.  

2 1583
Luuk
1,047 Expert 1GB
Because substr start counting from 0, untested:
Expand|Select|Wrap|Line Numbers
  1. $a = substr($data, 19-1, 51-19+1);
  2. $b = substr($data, 53-1, 112-53+1);
  3.  
May 29 '14 #2
nine72
21
I just tried this and i cant believe that it was that easy. I spent a week doing everything I could think of including regx for this. Thank you so much, now maybe i can get this project off my list!

I guess my pic says it all for me on this one lol.
May 29 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Patrick De Ridder | last post by:
When I code Double.Parse(textBox1.Text) I get an error How can I convert a text box entry to a numeric? Please give a code example, if you know the answer.
2
by: .Net Sports | last post by:
I'm trying to parse some text from an open file , and then save it and display it, but with the code below, using two instances of IndexOf doesnt work (error: length cannot be less than zero.), and...
5
by: liming | last post by:
Hi all, I have to parse two text files on a weekly basis. Each range from 300kb to 1mb in total. Each text file has 5 columns (name,id, dollar, startdate,enddate), everytime, a) I need to...
3
by: Bill nguyen | last post by:
I'm looking for a good routine to parse the following text pattern: a:18: {i:0;i:408;i:1;i:409;i:2;i:410;i:3;i:411;i:4;i:413;i:5;i:414;} a: = page_id a:18 -page_id = 18 Those within curly...
1
by: akkarthikeyan | last post by:
hi everyone, i am having a text file in the format account=somevalue username=program i want to parse the file and retrieve the result as per user req, suppose if user enter account it...
1
by: mscw | last post by:
Hi, I'm trying parse a text file I'm pulling into VB6, but am unable to do like I usually do (Line Input/Print) since the text file inserts two carriage returns at the end of each line instead of...
0
by: ghostface | last post by:
**How do I parse a textfile and edit only a certain part of it. Specifically, just the last column. My textfile looks like this. #Server Group 1...
2
by: dpw.asdf | last post by:
I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to...
8
by: scad | last post by:
I have a file that has blocks of data that can vary in length. The first 2 bytes of the block are a Hex number telling me how many bytes long the block is (including those 2 bytes). I need to be...
1
by: autumnrrr | last post by:
th {height:50px;} td {padding:15px;} th {background-color:#0099cc;color:black;} .m {background-color:#7a52cc;color:black;} .t {background-color:#8a5ce6;color:black;} .b...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.