0

i have a file that contain repetitive code like this an i just want to

swap a roll/column? (how to say?) of y and z , every number is different in here nothing in here is same number

Example:

xxxx,xxxx,yyyy,xxxx,xxxx,zzzz:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,yyyy,xxxx,xxxx,zzzz:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,yyyy,xxxx,xxxx,zzzz:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,yyyy,xxxx,xxxx,zzzz:xxxx:xxxx:xxxx:xxxx:

Into:

xxxx,xxxx,zzzz,xxxx,xxxx,yyyy:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,zzzz,xxxx,xxxx,yyyy:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,zzzz,xxxx,xxxx,yyyy:xxxx:xxxx:xxxx:xxxx:
xxxx,xxxx,zzzz,xxxx,xxxx,yyyy:xxxx:xxxx:xxxx:xxxx:

x , y , z = different numbers

sorry for poor explanation

example

 36,192,72004,128,0,71923:0:0:0:0:
 256,192,72014,128,0,71843:0:0:0:0:
 475,192,72204,128,0,71923:0:0:0:0:

to

 36,192,71923,128,0,72004:0:0:0:0:
 256,192,71843,128,0,72014:0:0:0:0:
 475,192,71923,128,0,72204:0:0:0:0:
KenZync
  • 13
  • 2
  • You can use a regex find-and-replace for this. Assuming that all of the x's represent different numbers, the only thing to anchor your search against is the commas and colons. A substitution like `/([^,]*,)([^,]*)/` will match against `yyyy` in the second group. – jpaugh Jul 27 '17 at 16:54
  • @jpaugh I'm new to here. Thanks for help but i don't know how to use regex. I know only how to use the ctrl+h in editplus/notepad++ – KenZync Jul 27 '17 at 17:08
  • Notepad++ supports [regexs](https://en.wikipedia.org/wiki/Regex), which is why I mentioned it. I recommend learning them if you have this sort of problem often. You can learn them in a few afternoons by reading up, and trying things out in your editor. – jpaugh Jul 27 '17 at 18:07
  • Welcome to [so]! This question would be a better fit for [su], but even there it might get down votes. Not sure. – jpaugh Jul 27 '17 at 18:08
  • your question is not about programming per-se, which is probably why it got down-voted. [SU] is about how to use applications, and is a better fit. – jpaugh Jul 27 '17 at 20:27

1 Answers1

1

his should do the job (in Notepad++):

  • Ctrl+H
  • Find what: ^((?:[^,]+,){2})(\d+),((?:[^,]+,){2})(\d+)
  • Replace with: $1$4,$3$2
  • Replace all

Explanation:

^           : start of line
(           : start group 1
  (?:       : start non capture group
    [^,]+   : 1 or more non comma
    ,       : a comma
  ){2}      : end group, must appear twice
)           : end group 1 
(\d+)       : group 2, 1 or more digits 
,           : a comma
(           : start group 3
  (?:       : start non capture group
    [^,]+   : 1 or more non comma
    ,       : a comma
  ){2}      : end group, must appear twice
)           : end group 3
(\d+)       : group 4, 1 or more digits

Replacement:

$1$4,$3$2   : group 1 group 4  comma group 3 group 4
jpaugh
  • 6,634
  • 4
  • 38
  • 90
Toto
  • 89,455
  • 62
  • 89
  • 125
  • Does that work in Notepad++, or EditPlus, or some other editor? – jpaugh Jul 27 '17 at 18:05
  • Thankyou its working! Notepadd++ Search Mode : Regular Expression / RegExr also working for this code! thank you so much! btw Who is downvote my question lol?This will help me a lot of thing for my day – KenZync Jul 27 '17 at 18:34
  • @jpaugh: It works in Npp, I don't know for other editors. – Toto Jul 27 '17 at 20:24