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























  • in this sample BA must start with 1 and end to 4
    – mohsen taherzadeh
    Nov 10 at 10:14






  • 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
    Nov 10 at 10:16






  • 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
    Nov 10 at 10:18










  • Regex is your friend.
    – Michal
    Nov 10 at 10:20














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























  • in this sample BA must start with 1 and end to 4
    – mohsen taherzadeh
    Nov 10 at 10:14






  • 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
    Nov 10 at 10:16






  • 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
    Nov 10 at 10:18










  • Regex is your friend.
    – Michal
    Nov 10 at 10:20












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















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















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 11:13









Michal

9261020




9261020










asked Nov 10 at 10:09









mohsen taherzadeh

13




13











  • in this sample BA must start with 1 and end to 4
    – mohsen taherzadeh
    Nov 10 at 10:14






  • 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
    Nov 10 at 10:16






  • 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
    Nov 10 at 10:18










  • Regex is your friend.
    – Michal
    Nov 10 at 10:20
















  • in this sample BA must start with 1 and end to 4
    – mohsen taherzadeh
    Nov 10 at 10:14






  • 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
    Nov 10 at 10:16






  • 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
    Nov 10 at 10:18










  • Regex is your friend.
    – Michal
    Nov 10 at 10:20















in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
Nov 10 at 10:14




in this sample BA must start with 1 and end to 4
– mohsen taherzadeh
Nov 10 at 10:14




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
Nov 10 at 10:16




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
Nov 10 at 10:16




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
Nov 10 at 10:18




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
Nov 10 at 10:18












Regex is your friend.
– Michal
Nov 10 at 10:20




Regex is your friend.
– Michal
Nov 10 at 10:20












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
    Nov 10 at 13:01










  • unfortunately don't work
    – mohsen taherzadeh
    Nov 11 at 5:13










  • @mohsentaherzadeh what's the problem?
    – roozbeh S
    Nov 11 at 6:05










  • 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
    Nov 11 at 8:25











  • Hope this edit helps
    – roozbeh S
    Nov 11 at 9:02










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



);













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















Required, but never shown

























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
    Nov 10 at 13:01










  • unfortunately don't work
    – mohsen taherzadeh
    Nov 11 at 5:13










  • @mohsentaherzadeh what's the problem?
    – roozbeh S
    Nov 11 at 6:05










  • 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
    Nov 11 at 8:25











  • Hope this edit helps
    – roozbeh S
    Nov 11 at 9:02














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
    Nov 10 at 13:01










  • unfortunately don't work
    – mohsen taherzadeh
    Nov 11 at 5:13










  • @mohsentaherzadeh what's the problem?
    – roozbeh S
    Nov 11 at 6:05










  • 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
    Nov 11 at 8:25











  • Hope this edit helps
    – roozbeh S
    Nov 11 at 9:02












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 Nov 11 at 9:02

























answered Nov 10 at 10:30









roozbeh S

6961410




6961410











  • 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
    Nov 10 at 13:01










  • unfortunately don't work
    – mohsen taherzadeh
    Nov 11 at 5:13










  • @mohsentaherzadeh what's the problem?
    – roozbeh S
    Nov 11 at 6:05










  • 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
    Nov 11 at 8:25











  • Hope this edit helps
    – roozbeh S
    Nov 11 at 9:02
















  • 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
    Nov 10 at 13:01










  • unfortunately don't work
    – mohsen taherzadeh
    Nov 11 at 5:13










  • @mohsentaherzadeh what's the problem?
    – roozbeh S
    Nov 11 at 6:05










  • 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
    Nov 11 at 8:25











  • Hope this edit helps
    – roozbeh S
    Nov 11 at 9:02















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
Nov 10 at 13:01




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
Nov 10 at 13:01












unfortunately don't work
– mohsen taherzadeh
Nov 11 at 5:13




unfortunately don't work
– mohsen taherzadeh
Nov 11 at 5:13












@mohsentaherzadeh what's the problem?
– roozbeh S
Nov 11 at 6:05




@mohsentaherzadeh what's the problem?
– roozbeh S
Nov 11 at 6:05












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
Nov 11 at 8:25





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
Nov 11 at 8:25













Hope this edit helps
– roozbeh S
Nov 11 at 9:02




Hope this edit helps
– roozbeh S
Nov 11 at 9:02

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




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















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus