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"









share|improve this question









New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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














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"









share|improve this question









New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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












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"









share|improve this question









New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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#






share|improve this question









New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Michal

817818




817818






New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









mohsen taherzadeh

11




11




New contributor




mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






mohsen taherzadeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • 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






  • 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












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





share|improve this answer






















  • 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










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',
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
);



);






mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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






























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





share|improve this answer






















  • 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














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





share|improve this answer






















  • 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












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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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










mohsen taherzadeh is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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














































































這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto