Line copy and place?
-
I want to copy & to & and paste it in ----- but i have 891 different lines of ** to *
“prop_user_&models/props_trainstation/train_outro_car01.mdl&”:{“string”:“-----”,“type”:“prop”,“print”:“-----”,“usergroup”:“user”}} -
891 different lines of & to &
-
Unfortunately, you’ve not phrased your post in the form of a question or a request for help that I can understand. I cannot tell what you mean by “copy & to & and paste it in”, or what is meant by “** to *”
You haven’t provided much information (see this FAQ), so it’s really hard to tell what you have or what you want.
I suggest you provide an example file. See @Scott-Sumner’s “help with Markdown in this forum” post, and my recent followup at the end of that thread, for how to embed an example file: you can watch the PREVIEW-pane to the right of the COMPOSE-pain when typing your reply, to see how the forum will format the post; try to fix it so it properly displays the data you are posting. There are two important aspects: 1) we need the data that we see to accurately reflect your data: the data you posted appears to have smart quotes, and I am guessing you meant those to be normal quotes, but that’s only a guess. By following the formatting advice in the post I just directed you to, we will be more certain that the data we are seeing matches what data you actually have. 2) The data needs to accurately reflect the possible variations in your data that need to match (and if there will be lines that don’t need to match, we need to know that too, so that it won’t accidentally match what it’s supposed to.). However, you do NOT have to show all 891 lines. Just show a few matching lines, and a few lines that don’t match – making sure that you’ve shown a reasonable variety, and clearly indicated matches vs non-matches.
Along with showing us what you currently have, you also need to show us what you want, so we can understand how you want this data transformed.
After you have posted that, while waiting for our replies, it would help if you also read the following, along with the links it points you to. This will help you with search-and-replace questions.
-----FYI: if you have further search-and-replace (regex) needs, study this FAQ and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting the data so that the forum doesn’t mangle it (so that it shows “exactly”, as I said earlier), see this help-with-markdown post, where @Scott-Sumner gives a great summary of how to use Markdown for this forum’s needs.
Please note that for all “regex” queries – or queries where you want help “matching” or “marking” or “bookmarking” a certain pattern, which amounts to the same thing – it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.
-----a wild guess
Reading your post a few more times, I am going to take a stab at interpreting what you have, and what you want.
I am assuming you have data of the form:"prop_user_&models/props_trainstation/train_outro_car01.mdl&":{"string":"-----","type":"prop","print":"-----","usergroup":"user"}} "prop_user_&some other text here&":{"string":"-----","type":"prop","print":"-----","usergroup":"user"}} "prop_user_~this one should not match because it is not between ampersands~":{"string":"-----","type":"prop","print":"-----","usergroup":"user"}}
and you want to replace it with
"prop_user_&models/props_trainstation/train_outro_car01.mdl&":{"string":"models/props_trainstation/train_outro_car01.mdl","type":"prop","print":"models/props_trainstation/train_outro_car01.mdl","usergroup":"user"}} "prop_user_&some other text here&":{"string":"some other text here","type":"prop","print":"some other text here","usergroup":"user"}} "prop_user_~this one should not match because it is not between ampersands~":{"string":"-----","type":"prop","print":"-----","usergroup":"user"}}
Unfortunately, (assuming you might have different numbers of groups of five hyphens) I haven’t been able to get it in one go (I’m only a mid-level regex user), but if you do multiple of the following search and replace (only 2 needed if there are never more than two
-----
to replace on a given line), it should eventually make it:- Find =
(?-s)(?:\&)(.+)(?:\&)(.*?)(-----)
- Replace =
\&$1\&$2$1
- Search Mode = Regular Expression
The links given will explain it in detail… but basically, the find expression
(?-s)
makes sure it will only match on a single line (so matches won’t wrap across lines)(?:\&)
looks for a literal&
character(.+)
looks for one or more characters, and places it into the$1
(aka\1
) placeholder(?:\&)
… followed by another&
(.*?)
matches all the characters after the second&
until it finds the next token, and places it into the$2
(aka\2
) placeholder(-----)
the literal sequence of five hyphens- anything from the hyphens to the end of the line is left alone
The replace expression replaces all that with
- ampersand, followed by the text that was between ampersands, and the final ampersand (so the first part of the line is unchanged)
- then all of the misc-text found and stored in
$2
(still unchanged) - now, instead of the five hyphens, it does a copy of the
$1
found between the ampersands. - anything from that to the end of the line is left alone (so still exists after the replace)
If your text will always have exactly two sets of five hyphens, then rather than having to run the above expression twice, you could:
- Find =
(?-s)(?:\&)(.+)(?:\&)(.*?)(-----)(.*?)(-----)
- Replace =
\&$1\&$2$1$4$1
- Search Mode = Regular Expression
This behaves similarly, but grabs two groups of anything followed by five hyphens, and it will automatically replace both.
But all of this is a wild guess, since I’m really not sure if that’s what you were asking for at all.
Good luck.
- Find =
-
Wow @PeterJones … so much effort … for an OP that wanted to put very-close-to-zero effort into it. I don’t know whether to commend you or to laugh at you. :)
-
Laughing is probably best.
I hadn’t posted over the weekend, so I was feeling deprived. (Or is that depraved. 😉).
-
its depraved, definitively depraved 😂😂😂
glad you’re here, i’m a bit (compulsively) hypersensitive to even short offline periods of core members at the moment … i promise i’ll try to work on desensitising a bit ;-)btw: there was an unusually low amount of new or funny questions this weekend (perceived), so thankfully not much to miss or catch up with.