Add 'G1' to the start of each line.
-
Sorry noob here… I am writing a G-Code program for my home made cnc. My thing is I need to add ‘G1’ to the start of each line and as I have over 12,000 lines I don’t want to do each line in turn…
Is there a way to use find and replace to do this automatically?Any help would be great.
-
Hello, @cnc-builder
Elementary task with regular expressions, indeed !!
-
Move back to the very beginning of the file to change (
Ctrl + Origin) -
Open the Find/Replace dialog (
Ctrl + H) -
Type
^, in the Find what: box -
Type
G1, in the Replace with: box -
Choose the Regular expression search mode
-
Click on the Replace All button
Et voilà !
Notes :
-
The
^character is the symbol, meaning “beginning of line”, in regular expressions -
If you prefer to separate the string G1 from the rest of text, you may, either, add a space character after G1 or the symbol
\t, for a tabulation character
Best regards,
guy038
P.S. :
For newby people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :
http://docs.notepad-plus-plus.org/index.php/Regular_Expressions
In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by
Notepad++, since its6.0version, at the TWO addresses below :http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
-
The FIRST link explains the syntax, of regular expressions, in the SEARCH part
-
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part
You may, also, look for valuable informations, on the sites, below :
http://www.regular-expressions.info
http://perldoc.perl.org/perlre.html
Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))
-
-
Many thanks did just what I needed great help :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login