Answer the question
In order to leave comments, you need to log in
How to parse the desired part of the text?
Tell me, please, how to unload information about
tel-179->
your-email->
_wpcf7->104
_wpcf7_version->4.7
_wpcf7_locale->ru_RU
_wpcf7_unit_tag->wpcf7-f104-p157-o3
_wpnonce->2b8273a977
your-name->Krisan Lang
menu-968->Firma
text-463->Best OÜ
tel-179- >58813468606
your-email->[email protected]
November 29, 2017, 18:07:14
_wpcf7->104
_wpcf7_version->4.7
_wpcf7_locale-> en_RU _wpcf7_unit_tag-
>wpcf7-f104-p67-o1
_wpnonce-3>
name->Liis dfValma
menu-968->Eraisik
text-463->
tel-179->5396643367
your-email->[email protected]
Answer the question
In order to leave comments, you need to log in
a) write a parser based on regular expressions
b) load into a text editor, sort, leave only the lines you need, copy them to the clipboard, open openOffice, paste (by specifying the separator ' -> '
The array will contain records of the form [0 => [], 1 => []] , it remains only to go through the array foreach and save it in the desired form (csv, tsv, ...)
<?php
function parse($text) {
$lines = explode("\n", $text);
$result = [];
$switched = false;
$i = 0;
foreach($lines as $line) {
// Add item
if (count($matches = preg_split('/->/', $line, -1, PREG_SPLIT_NO_EMPTY)) == 2) {
if (!isset($result[$i])) {
$result[$i] = [];
}
$result[$i][$matches[0]] = $matches[1];
$switched = false;
} else if (!$switched) {
$i++;
$switched = true;
}
}
return $result;
}
$text = "
_wpcf7->104
_wpcf7_version->4.7
_wpcf7_locale->ru_RU
_wpcf7_unit_tag->wpcf7-f104-p157-o3
_wpnonce->2b8273a977
your-name->Krisan Lang
menu-968->Firma
text-463->Best OÜ
tel-179->58813468606
your-email->[email protected]
November 29, 2017, 18:07:14
_wpcf7->104
_wpcf7_version->4.7
_wpcf7_locale->ru_RU
_wpcf7_unit_tag->wpcf7-f104-p67-o1
_wpnonce->2b8273a977
your-name->Liis dfValma
menu-968->Eraisik
text-463->
tel-179->5396643367
your-email->[email protected]
";
print_r(parse($text));
In your case, everything is done in a couple of clicks without scripts.
1. Insert your text into Excel
2. Split into columns, separator ">" (judging by the piece of text, this character is unique. If not, then first, through ctrl + a, replace "->" with some rare character that definitely does not exist in your text, for example, "No." Then do "separation by columns" by this character)
3. Apply a text filter on the first column, for "tel-" and "your-email"
4. Copy the filtered values to a new sheet.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question