find specfic tag and order by number
up vote
-2
down vote
favorite
I have a text that I want to go after finding a specific tag for example BA all the numbers in the order.
FORM_ADS BA="1" BB="103" BC="000055512100" BD="0" BE="1" BF="13970806" S="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="15721120" CB="0" EB="13388" BAA="13313880" BAB="14793200" BAC="0" BAD="927920" BAE="0" BAF="-3416408"
FORM_ADS BA="2" BB="103" BC="000050476860" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="14326424" CB="0" EB="13376" BAA="11238300" BAB="12487000" BAC="0" BAD="1839424" BAE="0" BAF="-3022728"
FORM_ADS BA="1" BB="103" BC="001740832930" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="18814350" CB="0" EB="13388" BAA="16025580" BAB="17806200" BAC="0" BAD="1008150" BAE="0" BAF="-3034878"
FORM_ADS BA="2" BB="103" BC="000050095071" BD="0" BE="1" BF="13970901" BR="0000106933" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="3296900" CB="0" EB="8357" BAA="2967210" BAB="0" BAC="0" BAD="0" BAE="0" BAF="740378"
c#
New contributor
add a comment |
up vote
-2
down vote
favorite
I have a text that I want to go after finding a specific tag for example BA all the numbers in the order.
FORM_ADS BA="1" BB="103" BC="000055512100" BD="0" BE="1" BF="13970806" S="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="15721120" CB="0" EB="13388" BAA="13313880" BAB="14793200" BAC="0" BAD="927920" BAE="0" BAF="-3416408"
FORM_ADS BA="2" BB="103" BC="000050476860" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="14326424" CB="0" EB="13376" BAA="11238300" BAB="12487000" BAC="0" BAD="1839424" BAE="0" BAF="-3022728"
FORM_ADS BA="1" BB="103" BC="001740832930" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="18814350" CB="0" EB="13388" BAA="16025580" BAB="17806200" BAC="0" BAD="1008150" BAE="0" BAF="-3034878"
FORM_ADS BA="2" BB="103" BC="000050095071" BD="0" BE="1" BF="13970901" BR="0000106933" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="3296900" CB="0" EB="8357" BAA="2967210" BAB="0" BAC="0" BAD="0" BAE="0" BAF="740378"
c#
New contributor
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
2
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
2
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
Regex is your friend.
– Michal
2 days ago
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I have a text that I want to go after finding a specific tag for example BA all the numbers in the order.
FORM_ADS BA="1" BB="103" BC="000055512100" BD="0" BE="1" BF="13970806" S="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="15721120" CB="0" EB="13388" BAA="13313880" BAB="14793200" BAC="0" BAD="927920" BAE="0" BAF="-3416408"
FORM_ADS BA="2" BB="103" BC="000050476860" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="14326424" CB="0" EB="13376" BAA="11238300" BAB="12487000" BAC="0" BAD="1839424" BAE="0" BAF="-3022728"
FORM_ADS BA="1" BB="103" BC="001740832930" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="18814350" CB="0" EB="13388" BAA="16025580" BAB="17806200" BAC="0" BAD="1008150" BAE="0" BAF="-3034878"
FORM_ADS BA="2" BB="103" BC="000050095071" BD="0" BE="1" BF="13970901" BR="0000106933" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="3296900" CB="0" EB="8357" BAA="2967210" BAB="0" BAC="0" BAD="0" BAE="0" BAF="740378"
c#
New contributor
I have a text that I want to go after finding a specific tag for example BA all the numbers in the order.
FORM_ADS BA="1" BB="103" BC="000055512100" BD="0" BE="1" BF="13970806" S="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="15721120" CB="0" EB="13388" BAA="13313880" BAB="14793200" BAC="0" BAD="927920" BAE="0" BAF="-3416408"
FORM_ADS BA="2" BB="103" BC="000050476860" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="14326424" CB="0" EB="13376" BAA="11238300" BAB="12487000" BAC="0" BAD="1839424" BAE="0" BAF="-3022728"
FORM_ADS BA="1" BB="103" BC="001740832930" BD="0" BE="1" BF="13970806" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="18814350" CB="0" EB="13388" BAA="16025580" BAB="17806200" BAC="0" BAD="1008150" BAE="0" BAF="-3034878"
FORM_ADS BA="2" BB="103" BC="000050095071" BD="0" BE="1" BF="13970901" BR="0000106933" BS="11111" BT="1" BU="1" BV="6" BW="0" BX="0" BYY="16" BZ="3296900" CB="0" EB="8357" BAA="2967210" BAB="0" BAC="0" BAD="0" BAE="0" BAF="740378"
c#
c#
New contributor
New contributor
edited 2 days ago
Michal
817818
817818
New contributor
asked 2 days ago
mohsen taherzadeh
11
11
New contributor
New contributor
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
2
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
2
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
Regex is your friend.
– Michal
2 days ago
add a comment |
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
2
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
2
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
Regex is your friend.
– Michal
2 days ago
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
2
2
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
2
2
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
Regex is your friend.
– Michal
2 days ago
Regex is your friend.
– Michal
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You can capture any BA="#" with regex and then replace it with BA="index":
// read your text
string allText = Filre.ReadAllText(path);
string format = "BA="(.*?)"";
int index = 1;
allText = Regex.Replace(allText, format, match => $"BA="index++"");
// now write your text back to file
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You can capture any BA="#" with regex and then replace it with BA="index":
// read your text
string allText = Filre.ReadAllText(path);
string format = "BA="(.*?)"";
int index = 1;
allText = Regex.Replace(allText, format, match => $"BA="index++"");
// now write your text back to file
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
|
show 1 more comment
up vote
0
down vote
accepted
You can capture any BA="#" with regex and then replace it with BA="index":
// read your text
string allText = Filre.ReadAllText(path);
string format = "BA="(.*?)"";
int index = 1;
allText = Regex.Replace(allText, format, match => $"BA="index++"");
// now write your text back to file
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
|
show 1 more comment
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can capture any BA="#" with regex and then replace it with BA="index":
// read your text
string allText = Filre.ReadAllText(path);
string format = "BA="(.*?)"";
int index = 1;
allText = Regex.Replace(allText, format, match => $"BA="index++"");
// now write your text back to file
You can capture any BA="#" with regex and then replace it with BA="index":
// read your text
string allText = Filre.ReadAllText(path);
string format = "BA="(.*?)"";
int index = 1;
allText = Regex.Replace(allText, format, match => $"BA="index++"");
// now write your text back to file
edited yesterday
answered 2 days ago
roozbeh S
63538
63538
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
|
show 1 more comment
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
enter code here string allText = System.IO.File.ReadAllText(path1); allText += "rn"; allText += System.IO.File.ReadAllText(path2); string format = "BA="(.*?)""; MatchCollection matches = Regex.Matches(allText, format); List<string> numbers = matches.Cast<Match>().Select(x => x.Value).Select(x => x.Split('"')[1]).ToList(); //now write to the created file System.IO.File.WriteAllText(newFilePath, allText);
– mohsen taherzadeh
2 days ago
unfortunately don't work
– mohsen taherzadeh
yesterday
unfortunately don't work
– mohsen taherzadeh
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
@mohsentaherzadeh what's the problem?
– roozbeh S
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
hi roozbeh ,this code dont work i have an string that save in alltext value,so i must find tag BA and sort all numbers by asc for exam first BA ia BA="1" and second BA="2" and third is BA="1" that change to 3 and forth BA="2" that must be equal to 4 until n value....
– mohsen taherzadeh
yesterday
Hope this edit helps
– roozbeh S
yesterday
Hope this edit helps
– roozbeh S
yesterday
|
show 1 more comment
mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.
mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.
mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.
mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237903%2ffind-specfic-tag-and-order-by-number%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
2 days ago
2
Welcome to StackOverflow! Please read stackoverflow.com/questions/how-to-ask. Please show what you've tried so far and where you are having a problem.
– JohnB
2 days ago
2
It would be awesome if you could provide a Minimal, Complete, and Verifiable example with sample inputs, and expected results based on those sample inputs.
– mjwills
2 days ago
Regex is your friend.
– Michal
2 days ago