String value with dots changed while assignig to "..(class).." - Google Apps Script - string

I have a problem with assigning a string value containg dots to a variable.
For example, after using this assignment:
var txt = "company.com.en";
the variable txt is set to "company.(class)"
How to avoid this behaviour, I want to keep this value unchanged.

OK, I've found my problem. It is really silly, but it is a feature of Debug viewer in Google Apps Script. String variables with dots are shown in this way (with ".(class)" string included). The oryginal value of variable remains unchanged. So, case closed.

Related

Operating on a file with overly long name

When I set up the ProtonMail Bridge CLI, it generated a hierarchy in my .password-store where the top level is called protonmail-credentials. This contains a subfolder where the name is a gibberish string enclosed in single quotes with--according to wc -c--153 characters. The name of the item under this is itself a 93-character string.
I would like to be able to operate on this item with pass, but wildcards apparently don't work for paths in pass, and dealing with such absurdly long strings which differ from setup to setup by typing everything out is not at all viable.
I am able to isolate the subfolder name with ls -1 .password-store/protonmail-credentials, which gives me the string beginning 'cHJv and continuing onward. I thought I could assign this to an environment variable with export $LONGDIRNAME=$(ls -1 .password-store/protonmail-credentials), but bash throws a 'not a valid identifier' error and thinks I'm trying to set the variable to a string beginning `=cHJv. I do not know why it is adding a backtick and equals sign to the string before attempting to set the variable.
Renaming either of these breaks ProtonMail Bridge's functionality, so mv is not an option either. What should I do with these strings to make the usable in pass?

How to extract substring (path to folder) from string using batch script or PowerShell

I have been trying to remove in batch script "=" character from string by using this:
set Path_var=%Path_var:^==%
Unfortunately this does not work... I tried also some other common solutions like:
set Path_var=%Path_var:"="=%
set Path_var=%Path_var:'='=%
But without success. Maybe it would be worthy also to explain for what I need it as I am aware you may be able to provide better solution. I extract one line from xml configuration file. The line is following:
<burning addDicomViewer="true" finalizeMedium="true" dicomViewer="C:\user\App_folder\App-name_subfolder_1.1.1_Setup" burnVerification="true" numberOfCopies="0" cleanupProjectData="false" volumeName="Patient Medium"/>
I need to extract from this line this path: "C:\user\App_folder\App-name_subfolder_1.1.1_Setup" (The path will not always be the same)
My strategy was to simply remove definite number of characters before the path as I know this setting will always be the same and therefore the length of the string won`t change.
set /p Path_var= < temp_file01.txt
set Path_var=%Path_var:~81,100%
Then I wanted to use simply substitution to remove the rest. For example:
set Path_var=%Path_var:burnVerification=%
But I ran into problem that my string contains characters like "=" which I can not remove by this method. (Because obviously there are handled as operators) What I was also wondering is what I should do if there will be a space character in my path. Then when I attempt to remove the empty characters at the end I also invalidate my path.
I know batch scripts are not the best for manipulation with strings, but I do not have other choice as my boss want me to use scripting language which does not need compiling.
I asked my work colleague for help and he came with following PowerShell solution:
$path_temp_file01 = "C:\user\temp\tmpFile_backup_script01.txt"
$path_temp_file02 = "C:\user\temp\tmpFile_backup_script02.txt"
$string = [IO.File]::ReadAllText($path_temp_file01)
$Start = $string.IndexOf("C:")
$string = $string.substring($Start)
$End =$string.IndexOf("""")
$string = $string.substring(0,$End)
$string > $path_temp_file02
It works for me. I post it here in the case someone needs similar solution or has better idea how to do that.

Questions regarding Python replace specific texts

I'm writing a script to scrape from another website with Python, and I am facing this question that I have yet to figure out a method to resolve it.
So say I have set to replace this particular string with something else.
word_replace_1 = 'dv'
namelist = soup.title.string.replace(word_replace_1,'11dv')
The script works fine, when the titles are dv234,dv123 etc.
The output will be 11dv234, 11dv123.
However if the titles are, dv234, mixed with dvab123, even though I did not set dvab to be replaced with anything, the script is going to replace it to 11dvab123. What should I do here?
Also, if the title is a combination of alphabits,numbers and Korean characters, say DAV123ㄱㄴㄷ,
how exactly should I make it to only spitting out DAV123, and adding - in between alphabits and numbers?
Python - making a function that would add "-" between letters
This gives me the idea to add - in between all characters, but is there a method to add - between character and number?
the only way atm I can think of is creating a table of replacing them, for example something like this
word_replace_3 = 'a1'
word_replace_4 = 'a2'
.......
and then print them out as
namelist3 = soup.title.string.replace(word_replace_3,'a-1').replace(word_replace_4,'a-2')
This is just slow and not efficient. What would be the best method to resolve this?
Thanks.

Azure Logic App - simple condition to check for empty string variable fails

Solved
Issue was due to error in child action as Thomas pointed out, not the way I was checking the variable value.
I've got a variable that's been initialized earlier in the LA. Later on I'm trying to check if the variable is empty using a condition.
Here's the output from the run history:
It looks like the variable is an empty string at this point, however the condition fails without any helpful information.
I've also tried null or wrapping the variable in the empty command and comparing to true/false. All gave the same failure.
You can use the length function in the expression. I've found it helpful to also coallesce the value to an empty string before checking length.
For me placing an empty string between double quotes in a condition action to recognize the empty string works well.
Be aware however that once you enter the empty string in the condition action and save your logic app, if you afterwards go back in the designer and reopen the condition action the empty string enclosed in double quotes ("") is not displayed anymore.

How to save strings in matrixes in matlab

I want to have a matrix/cell, that has strings inside that I can access and use later as strings.
For instance, I have one variable (MyVar) and one cell (site) with names inside:
MyVar=-9999;
site={'New_York'; 'Lisbon'; 'Sydney'};
Then I want to do something like:
SitePosition=strcat(site{1},'_101'}
and then do this
save(sprintf('SitePosition%d',MyVar),);
This doesn't work at all! Is there a way to have strings in a matrix and access them in order to keep working with them if they were a string?
This:
MyVar=-9999; site={'New_York'; 'Lisbon'; 'Sydney'};
SitePosition = strcat(site{1},'_101');
save(sprintf('SitePosition%d',MyVar));
Works fine and yields SitePosition-9999.mat, note the syntax changes in lines 2 and 3.
Is there something else you're expecting?
EDIT: Based on your comment
Check out the documentation for save regarding saving specific variables
New example:
MyVar=-9999;
site={'New_York'; 'Lisbon'; 'Sydney'};
SitePosition = strcat(site{1},'_101');
save(SitePosition,'MyVar');
Creates New_York_101.mat with only the variable MyVar in it.

Resources