Can someone please tell me how this could be done?
I am having trouble using the "find and replace" command to covert this:
PRODUCTS 2::id DOCUMENTS::id PRODUCTS 2::note PRODUCTS 2::prnt_bleed_lr PRODUCTS 2::prnt_bleed_tb PRODUCTS 2::prnt_gutter_width PRODUCTS 2::prnt_material_width PRODUCTS 2::prnt_max_printable_height PRODUCTS 2::prnt_max_printable_width
to this:
getValue( PRODUCTS 2::id ; 1) ; getValue( DOCUMENTS::id ; 1) ; getValue( PRODUCTS 2::note ; 1) ; getValue( PRODUCTS 2::prnt_bleed_lr ; 1) ; getValue( PRODUCTS 2::prnt_bleed_tb ; 1) ; getValue( PRODUCTS 2::prnt_gutter_width ; 1) ; getValue( PRODUCTS 2::prnt_material_width ; 1) ; getValue( PRODUCTS 2::prnt_max_printable_height ; 1) ; getValue( PRODUCTS 2::prnt_max_printable_width ; 1) ;
I thought that I could simply:
find: \r replace with: ; 1) ; \r getValue(
This does not work. :(
Try using a regular expression like this..
http://carpii.homeip.net/skitch/Find-20160207-132857.png
The expression is ^.*::.*$
On 7 February 2016 at 13:20, J Galt jgaltusa@gmail.com wrote:
Can someone please tell me how this could be done?
I am having trouble using the "find and replace" command to covert this:
PRODUCTS 2::id DOCUMENTS::id PRODUCTS 2::note PRODUCTS 2::prnt_bleed_lr PRODUCTS 2::prnt_bleed_tb PRODUCTS 2::prnt_gutter_width PRODUCTS 2::prnt_material_width PRODUCTS 2::prnt_max_printable_height PRODUCTS 2::prnt_max_printable_width
to this:
getValue( PRODUCTS 2::id ; 1) ; getValue( DOCUMENTS::id ; 1) ; getValue( PRODUCTS 2::note ; 1) ; getValue( PRODUCTS 2::prnt_bleed_lr ; 1) ; getValue( PRODUCTS 2::prnt_bleed_tb ; 1) ; getValue( PRODUCTS 2::prnt_gutter_width ; 1) ; getValue( PRODUCTS 2::prnt_material_width ; 1) ; getValue( PRODUCTS 2::prnt_max_printable_height ; 1) ; getValue( PRODUCTS 2::prnt_max_printable_width ; 1) ;
I thought that I could simply:
- find: \r
- replace with: ; 1) ; \r getValue(
This does not work. :(
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Thanks very much, that worked great!
I am newbie and I am trying to understand everything that is going on in your expression.
Can you please help me understand what is happening between these two expressions?
^ beginning of the line
.*::.*
$ end of the line
also…
can you please tell me what the zero after the $ doing in this string?
getValue( $0; 1) ;
On Feb 7, 2016, at 7:29 AM, Carpii UK carpii.uk@gmail.com wrote:
Try using a regular expression like this..
http://carpii.homeip.net/skitch/Find-20160207-132857.png http://carpii.homeip.net/skitch/Find-20160207-132857.png
The expression is ^.*::.*$
Can you please help me understand what is happening between these two expressions?
^ beginning of the line
.*::.*
$ end of the line
^ match the beginning of the line
.* followed by 0 or more characters (apart from newline)
:: followed by 2 literal colon characters
.* followed by 0 or more characters (apart from newline)
$ followed by the end of the line (a \n character)
also…
can you please tell me what the zero after the $ doing in this string?
getValue( $0; 1) ;
The $0 is a way of referencing one of the captures the regular expression made I'm not entirely sure this capturing syntax is right, normally I use brackets to capture, yet it seems to work in textmate.
We need to do this otherwise we don't know what to output after getValue(
On Feb 7, 2016, at 7:29 AM, Carpii UK carpii.uk@gmail.com wrote:
Try using a regular expression like this..
http://carpii.homeip.net/skitch/Find-20160207-132857.png
The expression is ^.*::.*$
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
To learn more about RegEx, I can recommend Regexr.com http://regexr.com/3coa1 (with your case http://regexr.com/3coa1). It is based on the JavaScript implementation, so there are limits, but it's a good start.
As Carpii said, you define “capture groups” with parentheses. TextMate Find & Replace behaves like PHP's preg_match http://php.net/manual/en/function.preg-match.php, so the “entire match” is in |$0|. In this case you need the entire line unbroken, so that's why |$0| works.
If instead you want to change:
|PRODUCTS 2::prnt_material_width |
to
|getValue( PRODUCTS 2 ; prnt_material_width ; 1) ;|
You would need to match the two groups separately:
|^(.+)::(.+)$|
Replace with:
|getValue( $1 ; $2 ; 1) ;|
I use |+| instead of |*|, because |+| requires a minimum of 1 character. It's a habit.
And of course there are many practical applications to knowing regular expressions http://xkcd.com/208.
Rasmus
On 07/02/16 19.14, Carpii UK wrote:
Can you please help me understand what is happening between these two expressions? ^ beginning of the line .*::.* $ end of the line
^ match the beginning of the line
.* followed by 0 or more characters (apart from newline)
:: followed by 2 literal colon characters
.* followed by 0 or more characters (apart from newline)
$ followed by the end of the line (a \n character)
also… can you please tell me what the zero after the $ doing in this string? getValue( $0; 1) ;
The $0 is a way of referencing one of the captures the regular expression made I'm not entirely sure this capturing syntax is right, normally I use brackets to capture, yet it seems to work in textmate.
We need to do this otherwise we don't know what to output after getValue(
On Feb 7, 2016, at 7:29 AM, Carpii UK <carpii.uk@gmail.com <mailto:carpii.uk@gmail.com> > wrote: Try using a regular expression like this.. http://carpii.homeip.net/skitch/Find-20160207-132857.png The expression is ^.*::.*$
_______________________________________________ textmate mailing list textmate@lists.macromates.com <mailto:textmate@lists.macromates.com> http://lists.macromates.com/listinfo/textmate
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
In this case you need the entire line unbroken, so that's why $0 works.
Good point! I had a feeling it was working by accident but couldn't spot
why :-)
Rasmus On 07/02/16 19.14, Carpii UK wrote:
Can you please help me understand what is happening between these two expressions?
^ beginning of the line
.*::.*
$ end of the line
^ match the beginning of the line
.* followed by 0 or more characters (apart from newline)
:: followed by 2 literal colon characters
.* followed by 0 or more characters (apart from newline)
$ followed by the end of the line (a \n character)
also…
can you please tell me what the zero after the $ doing in this string?
getValue( $0; 1) ;
The $0 is a way of referencing one of the captures the regular expression made I'm not entirely sure this capturing syntax is right, normally I use brackets to capture, yet it seems to work in textmate.
We need to do this otherwise we don't know what to output after getValue(
On Feb 7, 2016, at 7:29 AM, Carpii UK <carpii.uk@gmail.com > wrote:
Try using a regular expression like this..
http://carpii.homeip.net/skitch/Find-20160207-132857.png http://carpii.homeip.net/skitch/Find-20160207-132857.png
The expression is ^.*::.*$
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
textmate mailing listtextmate@lists.macromates.comhttp://lists.macromates.com/listinfo/textmate
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Thanks very much guys for the explanation and the RegEx links.
I really appreciate it.
On Sun, Feb 7, 2016 at 7:20 AM, J Galt jgaltusa@gmail.com wrote:
Can someone please tell me how this could be done?
The reason your original search was failing is that new line is \n and you were searching for \r which is carriage return.