Split server log strings into array and read as index, also grep for keywordsGetting the last element of a split string arrayHow do I split a string into an array of characters?Split string into arrayHow to split an array indexSplit an array by its indexSplitting Javascript-String with keywords out of an arraySplit Javascript String into an array of strings by looking for keywordJavaScript array split at indexHow do I split the string into an array at an index?Javascript, uploading several files within an Array.reduce with Promises, how?

Insert or push_back to end of a std::vector?

Typesetting "hollow slash"

Is there a word for returning to unpreparedness?

Unconventional examples of mathematical modelling

Is Fourier series a sampled version of Fourier transform?

Can I use my OWN published papers' images in my thesis without Copyright infringment

How do I ask for 2-3 days per week remote work in a job interview?

If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?

Does writing regular diary entries count as writing practice?

Is a USB 3.0 device possible with a four contact USB 2.0 connector?

Good way to stop electrolyte tabs from turning into powder?

Units of measurement, especially length, when body parts vary in size among races

Do I need to start off my book by describing the character's "normal world"?

Does the Haste spell's hasted action allow you to make multiple unarmed strikes? Or none at all?

What allows us to use imaginary numbers?

Why don't modern jet engines use forced exhaust mixing?

Escape Velocity - Won't the orbital path just become larger with higher initial velocity?

What is the opposite of "hunger level"?

Setting up a Mathematical Institute of Refereeing?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

May the tower use the runway while an emergency aircraft is inbound?

Ghost house where the house only appeared once a year for it was the ghost

How to get locks that are keyed alike?

Quick destruction of a helium filled airship?



Split server log strings into array and read as index, also grep for keywords


Getting the last element of a split string arrayHow do I split a string into an array of characters?Split string into arrayHow to split an array indexSplit an array by its indexSplitting Javascript-String with keywords out of an arraySplit Javascript String into an array of strings by looking for keywordJavaScript array split at indexHow do I split the string into an array at an index?Javascript, uploading several files within an Array.reduce with Promises, how?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm able to select and read a local file using the code below:



Structure of my local file i'm reading looks like this.



27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6


My problem is I want to be able to split the file into an array and output parts as index



i.e.



#0| 27/03/19 #1| 12:36:18:199 #2| LINE 5 #3| LINE 5.1
data[2] = LINE 5


Also be able grep for a keyword and out put that .



Nb. the file is a server log so would need to be read in realtime.



Thanks in advance for your answers,
Cody



<img id='output'>
<script>
var openFile = function(event)
var input = event.target;

var reader = new FileReader();
reader.onload = function()
var text = reader.result;
console.log(reader.result);
;
reader.readAsText(input.files[0]);
;
</script>









share|improve this question


























  • client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

    – Nikos M.
    Mar 27 at 12:38











  • So best using something like nodeJS right?

    – Cody
    Mar 27 at 12:40











  • node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

    – Nikos M.
    Mar 27 at 12:41











  • About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

    – Kévin Bibollet
    Mar 27 at 12:49


















0















I'm able to select and read a local file using the code below:



Structure of my local file i'm reading looks like this.



27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6


My problem is I want to be able to split the file into an array and output parts as index



i.e.



#0| 27/03/19 #1| 12:36:18:199 #2| LINE 5 #3| LINE 5.1
data[2] = LINE 5


Also be able grep for a keyword and out put that .



Nb. the file is a server log so would need to be read in realtime.



Thanks in advance for your answers,
Cody



<img id='output'>
<script>
var openFile = function(event)
var input = event.target;

var reader = new FileReader();
reader.onload = function()
var text = reader.result;
console.log(reader.result);
;
reader.readAsText(input.files[0]);
;
</script>









share|improve this question


























  • client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

    – Nikos M.
    Mar 27 at 12:38











  • So best using something like nodeJS right?

    – Cody
    Mar 27 at 12:40











  • node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

    – Nikos M.
    Mar 27 at 12:41











  • About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

    – Kévin Bibollet
    Mar 27 at 12:49














0












0








0








I'm able to select and read a local file using the code below:



Structure of my local file i'm reading looks like this.



27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6


My problem is I want to be able to split the file into an array and output parts as index



i.e.



#0| 27/03/19 #1| 12:36:18:199 #2| LINE 5 #3| LINE 5.1
data[2] = LINE 5


Also be able grep for a keyword and out put that .



Nb. the file is a server log so would need to be read in realtime.



Thanks in advance for your answers,
Cody



<img id='output'>
<script>
var openFile = function(event)
var input = event.target;

var reader = new FileReader();
reader.onload = function()
var text = reader.result;
console.log(reader.result);
;
reader.readAsText(input.files[0]);
;
</script>









share|improve this question
















I'm able to select and read a local file using the code below:



Structure of my local file i'm reading looks like this.



27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6


My problem is I want to be able to split the file into an array and output parts as index



i.e.



#0| 27/03/19 #1| 12:36:18:199 #2| LINE 5 #3| LINE 5.1
data[2] = LINE 5


Also be able grep for a keyword and out put that .



Nb. the file is a server log so would need to be read in realtime.



Thanks in advance for your answers,
Cody



<img id='output'>
<script>
var openFile = function(event)
var input = event.target;

var reader = new FileReader();
reader.onload = function()
var text = reader.result;
console.log(reader.result);
;
reader.readAsText(input.files[0]);
;
</script>






javascript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 12:37









kemicofa

11.2k4 gold badges43 silver badges95 bronze badges




11.2k4 gold badges43 silver badges95 bronze badges










asked Mar 27 at 12:34









CodyCody

1




1















  • client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

    – Nikos M.
    Mar 27 at 12:38











  • So best using something like nodeJS right?

    – Cody
    Mar 27 at 12:40











  • node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

    – Nikos M.
    Mar 27 at 12:41











  • About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

    – Kévin Bibollet
    Mar 27 at 12:49


















  • client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

    – Nikos M.
    Mar 27 at 12:38











  • So best using something like nodeJS right?

    – Cody
    Mar 27 at 12:40











  • node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

    – Nikos M.
    Mar 27 at 12:41











  • About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

    – Kévin Bibollet
    Mar 27 at 12:49

















client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

– Nikos M.
Mar 27 at 12:38





client-side javascript CANNOT read file in real-time as it needs user input to open and read local file. Also have tries using regular expressions to split the contents of the file?

– Nikos M.
Mar 27 at 12:38













So best using something like nodeJS right?

– Cody
Mar 27 at 12:40





So best using something like nodeJS right?

– Cody
Mar 27 at 12:40













node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

– Nikos M.
Mar 27 at 12:41





node.js is server-side technology, so it depends on what is your application and purpose of reading the log file. But yes node.js can do it in real-time

– Nikos M.
Mar 27 at 12:41













About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

– Kévin Bibollet
Mar 27 at 12:49






About splitting your file content, you should use regular expressions. With ^((?:d2/?)3)s+((?:d2:)3d3)s+(.+)$, you will be able to separate date, time and line content (with line A and line A.B in the same group). This regex can be updated if your lines have separators, in order to split line A and line A.B.

– Kévin Bibollet
Mar 27 at 12:49













2 Answers
2






active

oldest

votes


















0














Reading Files



If it's a server log and you wish to handle this client side in realtime then you'll need to:



Server



  • Create a nodejs server that watches your log file for any modifications which can be done with fs.Watch and provides a socket connection

Client



  • Create a web socket that receives notifications from your server whenever your log file has changed with the data sent (note the server web connection library also offers a client side one which is supported on all browsers, check their examples to understand quickly)

  • Whenever new data is sent simply call the script below and update your view

Why create a separate server to handle this ?



  • Well if you're not running a nodejs server already, then creating a nodejs server is quick and easy.


  • It's a feature outside of what your main server is focused on doing


Handling Log Data:



Partial implementation on how to read the contents of your log file. You'll need to determine a pattern to be able to seperate LINE 5 LINE 5.1 as this current script simply splits on white spaces. If each LINE does not have any spaces then it'll work.






const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)








share|improve this answer

























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08


















0














After parsing the file contends by line, you can try the below snippet to get the contends with index , Assuming the line separators are "white spaces".






function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





The Above Snippet has been updated in the Code Pen , You can see the output in console.



[https://codepen.io/redhatvicky/pen/QoXLYw][1]





share|improve this answer



























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08











  • Thanks, but I don't see how I can select and have my my file in read in realtime?

    – Cody
    Mar 27 at 13:19











  • In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

    – redhatvicky
    Mar 27 at 17:04














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377335%2fsplit-server-log-strings-into-array-and-read-as-index-also-grep-for-keywords%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Reading Files



If it's a server log and you wish to handle this client side in realtime then you'll need to:



Server



  • Create a nodejs server that watches your log file for any modifications which can be done with fs.Watch and provides a socket connection

Client



  • Create a web socket that receives notifications from your server whenever your log file has changed with the data sent (note the server web connection library also offers a client side one which is supported on all browsers, check their examples to understand quickly)

  • Whenever new data is sent simply call the script below and update your view

Why create a separate server to handle this ?



  • Well if you're not running a nodejs server already, then creating a nodejs server is quick and easy.


  • It's a feature outside of what your main server is focused on doing


Handling Log Data:



Partial implementation on how to read the contents of your log file. You'll need to determine a pattern to be able to seperate LINE 5 LINE 5.1 as this current script simply splits on white spaces. If each LINE does not have any spaces then it'll work.






const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)








share|improve this answer

























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08















0














Reading Files



If it's a server log and you wish to handle this client side in realtime then you'll need to:



Server



  • Create a nodejs server that watches your log file for any modifications which can be done with fs.Watch and provides a socket connection

Client



  • Create a web socket that receives notifications from your server whenever your log file has changed with the data sent (note the server web connection library also offers a client side one which is supported on all browsers, check their examples to understand quickly)

  • Whenever new data is sent simply call the script below and update your view

Why create a separate server to handle this ?



  • Well if you're not running a nodejs server already, then creating a nodejs server is quick and easy.


  • It's a feature outside of what your main server is focused on doing


Handling Log Data:



Partial implementation on how to read the contents of your log file. You'll need to determine a pattern to be able to seperate LINE 5 LINE 5.1 as this current script simply splits on white spaces. If each LINE does not have any spaces then it'll work.






const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)








share|improve this answer

























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08













0












0








0







Reading Files



If it's a server log and you wish to handle this client side in realtime then you'll need to:



Server



  • Create a nodejs server that watches your log file for any modifications which can be done with fs.Watch and provides a socket connection

Client



  • Create a web socket that receives notifications from your server whenever your log file has changed with the data sent (note the server web connection library also offers a client side one which is supported on all browsers, check their examples to understand quickly)

  • Whenever new data is sent simply call the script below and update your view

Why create a separate server to handle this ?



  • Well if you're not running a nodejs server already, then creating a nodejs server is quick and easy.


  • It's a feature outside of what your main server is focused on doing


Handling Log Data:



Partial implementation on how to read the contents of your log file. You'll need to determine a pattern to be able to seperate LINE 5 LINE 5.1 as this current script simply splits on white spaces. If each LINE does not have any spaces then it'll work.






const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)








share|improve this answer













Reading Files



If it's a server log and you wish to handle this client side in realtime then you'll need to:



Server



  • Create a nodejs server that watches your log file for any modifications which can be done with fs.Watch and provides a socket connection

Client



  • Create a web socket that receives notifications from your server whenever your log file has changed with the data sent (note the server web connection library also offers a client side one which is supported on all browsers, check their examples to understand quickly)

  • Whenever new data is sent simply call the script below and update your view

Why create a separate server to handle this ?



  • Well if you're not running a nodejs server already, then creating a nodejs server is quick and easy.


  • It's a feature outside of what your main server is focused on doing


Handling Log Data:



Partial implementation on how to read the contents of your log file. You'll need to determine a pattern to be able to seperate LINE 5 LINE 5.1 as this current script simply splits on white spaces. If each LINE does not have any spaces then it'll work.






const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)








const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)





const data = `
27/03/19 12:36:18:193 LINE 1

27/03/19 12:36:18:198 LINE 2

27/03/19 12:36:18:198 LINE 3 LINE 3.1

27/03/19 12:36:18:199 LINE 4

27/03/19 12:36:18:199 LINE 5 LINE 5.1

27/03/19 12:36:25:045 LINE 6
`

const res = data
.trim()
.split(/n+/)
.map(line=>line.split(/s/));

console.log(res)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 13:00









kemicofakemicofa

11.2k4 gold badges43 silver badges95 bronze badges




11.2k4 gold badges43 silver badges95 bronze badges















  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08

















  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08
















Hey, do you have a full working script you can share as I tried to add your block of but not working.

– Cody
Mar 27 at 13:08





Hey, do you have a full working script you can share as I tried to add your block of but not working.

– Cody
Mar 27 at 13:08













0














After parsing the file contends by line, you can try the below snippet to get the contends with index , Assuming the line separators are "white spaces".






function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





The Above Snippet has been updated in the Code Pen , You can see the output in console.



[https://codepen.io/redhatvicky/pen/QoXLYw][1]





share|improve this answer



























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08











  • Thanks, but I don't see how I can select and have my my file in read in realtime?

    – Cody
    Mar 27 at 13:19











  • In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

    – redhatvicky
    Mar 27 at 17:04
















0














After parsing the file contends by line, you can try the below snippet to get the contends with index , Assuming the line separators are "white spaces".






function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





The Above Snippet has been updated in the Code Pen , You can see the output in console.



[https://codepen.io/redhatvicky/pen/QoXLYw][1]





share|improve this answer



























  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08











  • Thanks, but I don't see how I can select and have my my file in read in realtime?

    – Cody
    Mar 27 at 13:19











  • In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

    – redhatvicky
    Mar 27 at 17:04














0












0








0







After parsing the file contends by line, you can try the below snippet to get the contends with index , Assuming the line separators are "white spaces".






function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





The Above Snippet has been updated in the Code Pen , You can see the output in console.



[https://codepen.io/redhatvicky/pen/QoXLYw][1]





share|improve this answer















After parsing the file contends by line, you can try the below snippet to get the contends with index , Assuming the line separators are "white spaces".






function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





The Above Snippet has been updated in the Code Pen , You can see the output in console.



[https://codepen.io/redhatvicky/pen/QoXLYw][1]





function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");





function parseContends(inputString)
if(inputString != null) [];
var stringArray = new Array();
for(var i =0; i < string.length; i++)
stringArray.push(string[i]);


console.log(stringArray);


parseContends("27/03/19 12:36:18:198 LINE 3 LINE 3.1");






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 27 at 13:15

























answered Mar 27 at 13:01









redhatvickyredhatvicky

4242 silver badges5 bronze badges




4242 silver badges5 bronze badges















  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08











  • Thanks, but I don't see how I can select and have my my file in read in realtime?

    – Cody
    Mar 27 at 13:19











  • In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

    – redhatvicky
    Mar 27 at 17:04


















  • Hey, do you have a full working script you can share as I tried to add your block of but not working.

    – Cody
    Mar 27 at 13:08











  • Thanks, but I don't see how I can select and have my my file in read in realtime?

    – Cody
    Mar 27 at 13:19











  • In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

    – redhatvicky
    Mar 27 at 17:04

















Hey, do you have a full working script you can share as I tried to add your block of but not working.

– Cody
Mar 27 at 13:08





Hey, do you have a full working script you can share as I tried to add your block of but not working.

– Cody
Mar 27 at 13:08













Thanks, but I don't see how I can select and have my my file in read in realtime?

– Cody
Mar 27 at 13:19





Thanks, but I don't see how I can select and have my my file in read in realtime?

– Cody
Mar 27 at 13:19













In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

– redhatvicky
Mar 27 at 17:04






In the real time , If the log files has to be parsed . There are two approaches one is you write a small javascript snippet which can pick up the log files in a periodical format and then parse the file line by line to apply the logic of splitting based on the delimiter. The second approach is the below approach which @kemikofa has mentioned.

– redhatvicky
Mar 27 at 17:04


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377335%2fsplit-server-log-strings-into-array-and-read-as-index-also-grep-for-keywords%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현