Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline fedeghi  
#1 Posted : 12 October 2021 15:56:42(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

Was thanked: 24 time(s) in 16 post(s)
Hi, is anybody aware of a method to find every occurrence of a "variable name" in a document, and replace it with another "new variable name" in every formula/occurence?
We have the built-in "find" (CTRL+F), but as far as I know it cannot replace also.

Does any plugin offer this feature?

Thanks
Bye

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 12 October 2021 16:18:54(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: fedeghi Go to Quoted Post
Hi, is anybody aware of a method to find every occurrence of a "variable name" in a document, and replace it with another "new variable name" in every formula/occurence?

No, not as per you demand.

Utilities Matrix Find_Replace.sm (24kb) downloaded 16 time(s).
Offline overlord  
#3 Posted : 12 October 2021 20:25:51(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,128
Turkey

Was thanked: 509 time(s) in 339 post(s)
There is F8 key for replacing variable when you are inside of a function, line, etc.
But there is not a global search and replace as far as I know.

Regards
Offline PompelmoTell  
#4 Posted : 12 October 2021 20:56:27(UTC)
PompelmoTell


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2011(UTC)
Posts: 319
Man
Italy
Location: italy

Was thanked: 109 time(s) in 93 post(s)
As a "sm" file is essentially an XML file, you can open it with an intelligent text editor (notepad ++) and do all the replacements with a special command

sergio
thanks 1 user thanked PompelmoTell for this useful post.
on 12/10/2021(UTC)
Offline fedeghi  
#5 Posted : 12 October 2021 21:56:31(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

Was thanked: 24 time(s) in 16 post(s)
Originally Posted by: overlord Go to Quoted Post
There is F8 key for replacing variable when you are inside of a function, line, etc.
But there is not a global search and replace as far as I know.

Thanks Overlord, I forgot to mention that I was referring to global "environment" instead of local variables inside a function Wink

Originally Posted by: PompelmoTell Go to Quoted Post
As a "sm" file is essentially an XML file, you can open it with an intelligent text editor (notepad ++) and do all the replacements with a special command

Thanks Sergio, I will give it a try, didn't think at this method
Offline Jean Giraud  
#6 Posted : 12 October 2021 22:11:30(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
F8.PNG
Offline Davide Carpi  
#7 Posted : 12 October 2021 22:14:15(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Text Region Utilities?

2016-02-06 19_46_29-.png 2016-02-06 19_48_50-.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 12/10/2021(UTC)
Offline fedeghi  
#8 Posted : 12 October 2021 22:44:38(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

Was thanked: 24 time(s) in 16 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Text Region Utilities?

Super! As usual... Clap
Offline overlord  
#9 Posted : 12 October 2021 23:39:35(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,128
Turkey

Was thanked: 509 time(s) in 339 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Text Region Utilities?

I wasn't using this on linux so totally forgot it.
While I was not using Search and Replace has been added.
It must be very long time since I had used it.

When I tried search&replace on linux there is that bug again.
Little blank squares are added front and end of variable.
Same cosmetic bug of Numeric UpDown Region.
But this time it effects variable names, not just cosmetic.

Regards
Offline fedeghi  
#10 Posted : 13 October 2021 10:21:57(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

Was thanked: 24 time(s) in 16 post(s)
Davide, is there a way / syntax that allows "Text Region Utilities" plugin to substitute some text with a new text containing greek letters?
Example:

Immagine 2021-10-13 092001.png

Thanks, bye
Offline Davide Carpi  
#11 Posted : 13 October 2021 13:41:58(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: overlord Go to Quoted Post
When I tried search&replace on linux there is that bug again.
Little blank squares are added front and end of variable.
Same cosmetic bug of Numeric UpDown Region.
But this time it effects variable names, not just cosmetic.

That's odd, nothing more than what you set as replacements should be added; I'll investigate it.

Originally Posted by: fedeghi Go to Quoted Post
Davide, is there a way / syntax that allows "Text Region Utilities" plugin to substitute some text with a new text containing greek letters?


You can use regular expressions, like this:

2021-10-13 12_35_21-.png

The syntax means:

SEARCH anything that starts (^) with (S) and a subscript (\.) and capture anything after it ((.*)) [parethesis are the "capture" group, the period means "any character" and the asterisk "zero or more times"; BTW the subscript symbol is escaped with \ because otherwise it means "any character" )

REPLACE with sigma (σ) a subscript (.) and the first of the captured strings ($1)

This might be simplified or much more complicated depending on the cases (what is available on the worksheet and the patterns)


More on regular expressions: C# Regular Expressions

A nice tool to test patterns, with live preview: regex101.com

Edited by user 13 October 2021 14:16:35(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline fedeghi  
#12 Posted : 13 October 2021 15:09:56(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

Was thanked: 24 time(s) in 16 post(s)
OK Davide, that's more or less the goal I had in mind, I'll need some more study about the proposed notation but you put me on the right path, thank you.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.