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#
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#
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
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#
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#
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
add a comment |
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
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
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
|
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
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
|
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
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
|
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 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
|
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
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
|
show 1 more comment
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.
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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
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