A
A
arti_djeims2016-08-09 23:29:53
JavaScript
arti_djeims, 2016-08-09 23:29:53

How to extract data from text?

If we receive data only in plain text format by type:

150
Cool Goods
Blah Blah Blah

So how do we create variables by ripping them out of such text? How to determine that the first line with numbers is a valid price and how to determine that 2 lines with text are the name, and everything else is a description? What are some ideas or tips?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
trushka, 2016-08-10
@arti_djeims

The question is not very clear. If there is always such an order (price-product-description), then you can type

var discription=str.split('\n'),
    price=discription[0],
    title=discription[1],
    comment=discription[2]

W
Worddoc, 2016-08-09
@Worddoc

Tear out - learn regular expressions
Determine the price or name - put the necessary data attribute in html and check

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question