1
I have a txt file that contains more than a thousand lines, each line has a number that needs to be validated by a javascript script that I have ready.
I would like some script in php or javascript to even read the file in txt, take it line by line and be validated with the other validation script I have, and when validating, if the line is failed in validation, that it be excluded or at least marked with some special character, but I prefer that it be removed even if.
Obs: I have Linux servers that could handle processing if the solution requires too much of the machine.
Simple check that would be used:
var numero = "55555555555"; // Aqui no caso seria puxado o arquivo em txt
if(numero.match(/55555555555/))
{ document.write("OK"); } else{
document.write("Nao Passou");}
Is there any way to do that?
This Javascript will be running in the browser or on the Node?
– Woss
In the browser ...
– Marcos
What kind of validation is that? You can put it together with the question?
– Woss
They are simple validations, but several, but an example would look like this: <script> var numero = "555555555555555"; // Here in case the txt file would be pulled if(numero.match(/55555555555/)){ Document.write("OK"); } Else{ Document.write("Not Passed"); } </script>
– Marcos
Ask the question, please. If they are simple validations, I recommend you implement them in PHP and do everything for this language. Use JS only if implementing this validation in PHP is not feasible.
– Woss
But there’s no way I can do it the way I explained it?
– Marcos
In PHP, yes. It’s very easy, but I need you to clarify in the question what kind of validations are these.
– Woss
Could you give me an example of how to do this in PHP if I were only to use a simple check if some line in the txt file found a numerical sequence, example 5555555555555? Because the rest I could change everything to php, I would only need an example.
– Marcos
You want to create the new txt file on the machine or on the server?
– Sam
What is more feasible, because the result of this would be only for me, I would not put for users to run via browser, only myself would run this.
– Marcos