Increment values/numbers in Sublime 3 - regex

I have multiple lines like this <VValue type="int" value="0" /> in files running in Sublime; each where the value increments 0, 1, 2, 3 etc...
I need to change these values, +60. So, 0 would become 60, 1 would be 61 etc.
How do I select the multiple lines and append them with regex in Sublime? I'm not sure of the command to select the number itself... something like \d+ was mentioned in another thread - Sublime Text 2 increment numbers
Note, I skip one number to separate some content in the software the files run in, so it really needs to be a +60 to the value command instead of just a direct replace all and increment (as in the thread above) as that would throw off the one that was skipped, if you follow me. For example, it could be 0, 1, 3, 4, 5 that should equal 60, 61, 63, 64, 65 and not 60, 61, 62, 63, 64.
Do I need something like TextPastry, and to use the Number Sequence Command? If so, I'm not sure how that works and would appreciate comments.
Thanks for any help :)
Edit; I think I can use the Auto Step feature in Text Pastry? Can someone kindly run me through this how to... install and use.

Unfortunately, Text pastry is not powerful enough (as far as I know). You need some evaluator package. We'll use Sublime-Evaluate here.
To install it (assuming you have package manager installed) simply
Command+Shift+p -> ip -> Enter -> evaluate -> Enter
Now just select the numbers you want to change (search with regex enabled):
(?<=<VValue type="int" value=")\d+(?=" />)
Alt+Enter. Now they are selected.
Right arrow to go after the selection. Type +60. Now Ctrl+Shift+← 3 times to select
0+60
1+60
...
n+60
on each line. Now Command+Shift+e and you are done (alternatively, you can Command+Shift+p -> evaluate -> Enter.

Related

HOW TO MAKE IF AND SEARCH STATEMENT GOOGLE SPREADSHEETS

So i have dropdown (cells J23) and when the dropdown gets the number, i want to show the results number (which is percent cell).
I was use filter, search and if function.
When i was run the if function, it's work. But when i was combine it, it doesn't work.
Here's my function
=filter(F10:G,search(J23,IF(J23 < 10, J23, IF(J23 = 10, 10, IF(J23 > 10, J23))), F10:F))
If you need my excel, you can access my google sheets
Your spreadsheet goal is hard to understand from your current formula. I think that you want the following...
In K21:
=IFERROR(VLOOKUP(J21,F6:G8,2,FALSE))
In K23:
=IFERROR(VLOOKUP(J23,F10:G,2,FALSE))
try:
=ARRAYFORMULA(IFERROR(QUERY(TO_TEXT(A5:C), "where 9=9 "&
IF(I6="",," and lower(Col1) contains '"&LOWER(I6)&"'")&
IF(J6="",," and lower(Col2) contains '"&LOWER(J6)&"'")&
IF(K6="",," and lower(Col3) contains '"&LOWER(K6)&"'")), "no match"))

How to extract a column based on it's content in PowerBI

I have a column in my table which looks like below.
ResourceIdentifier
------------------
arn:aws:ec2:us-east-1:7XXXXXX1:instance/i-09TYTYTY79716
arn:aws:glue:us-east-1:5XXXXXX85:devEndpoint/etl-endpoint
i-075656565f7fea3
i-02c3434343f22
qa-271111145-us-east-1-raw
prod-95756565631-us-east-1-raw
prod-957454551631-us-east-1-isin-repository
i-02XXXXXXf0
I want a new column called 'Trimmed Resource Identifier' which looks at ResourceIdentifier and if the value starts with "arn", then returns value after last "/", else returns the whole string.
For eg.
arn:aws:ec2:us-east-1:7XXXXXX1:instance/i-09TYTYTY79716  ---> i-09TYTYTY797168
i-02XXXXXXf0 --> i-02XXXXXXf0
How do I do this ? I tried creating a new column called "first 3 letters" by extracting first 3 letters of the ResourceIdentifier column but I am getting stuck at the step of adding conditional column. Please see the image below.
Is there a way I can do all of this in one step using DAX instead of creating a new intermediate column ?
Many Thanks
The GUI is too simple to do exactly what you want but go ahead and use it to create the next step, which we can then modify to work properly.
Filling out the GUI like this
will produce a line of code that looks like this (turn on the Formula Bar under the View tab in the query editor if you don't see this formula).
= Table.AddColumn(#"Name of Previous Step Here", "Custom",
each if Text.StartsWith([ResourceIdentifier], "arn") then "output" else [ResourceIdentifier])
The first three letters bit is already handled with the operator I chose, so all that remains is to change the "output" placeholder to what we actually want. There's a handy Text.AfterDelimiter function we can use for this.
Text.AfterDelimiter([ResourceIdentifier], "/", {0, RelativePosition.FromEnd})
This tells it to take the text after the first / (starting from the end). Replace "output" with this expression and you should be good to go.

Select files between specified range with regex

I have a folder with 100 folders, named like:
parent_folder/05/01/
parent_folder/05/02/
parent_folder/05/03/
parent_folder/05/04/
...
parent_folder/05/29/
parent_folder/05/30/
How can I specify a path, with regex, that would select only the contents of folders 01 to 10, then 11 to 20 and, finally, 21 to 30 ?
I am trying
"parent_folder/05/[1-10]*/*"
but it also selects 11, 12, ... all the way to 19.
EDIT: I want to read a large dataset in pyspark by 10-day intervals, and all suggested answers, so far, seem to fail.
If you want the "10" to be grouped with your 01...09 set, you are going to use something like this:
parent_folder\/05\/(0[1-9]|10)\/
then, for your 10...20 set,
parent_folder\/05\/(1[1-9]|20)\/
and so on.
You can try these regexps with the following link : https://regex101.com/r/cXAYbS/2
In python, you are going to need:
regex = r"parent_folder\/05\/(1[1-9]|20)\/"
The link above has a "python" generator, where you can borrow some code:
https://regex101.com/r/cXAYbS/2/codegen?language=python
How about this:
parent_folder/05/(?:0[1-9]|10)/
The '?:' is used for non-captering groups.

Regex validation on Account Address field

We sync our Salesforce accounts and opportunities to QuickBooks (QB), but QB has character limits on its fields. Street lines have a 41 character limit per line and I'm trying to have regex control and limit this, but it isn't working on the Address field type. I am using the very simple conditional formula:
REGEX(BillingStreet, '.{42,}')
which matches any non-linebreak character and if it's 42 characters or more, trigger the validation. The problem is that it ignores this rule. I know this formula works because if I apply it to another text field, it works how it's supposed to. Here's an example of how it should work: https://www.regexpal.com/99217. If there's a match anywhere, it should throw the validation error.
Any ideas?
I ended up not using Regex because it doesn't seem to work well. Instead I used formulas to make sure it follows the validation. Since we have a limit of two lines, it wasn't too bad to do this the long way.
AND(
IF(
//Look for a line break. If there is one, split and compare lengths separately.
FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet ) > 0
,
IF(
//If the first line is over the limit, return true to trigger validation.
LEN(LEFT(BillingStreet, FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet )-2))>41
,
TRUE
,
//If first line is fine, check second line and since this is a condition, it will return true/false automatically.
LEN(MID(BillingStreet, FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet )+1,LEN(BillingStreet))) > 41
)
,
//If there is no line break (one line) check the total length.
LEN(BillingStreet) > 41
)
,
//There is a validation for having more than 2 lines. Without this, it will combine lines 2 and above and check that length and will be confusing to users when it's > 41.
NOT(REGEX( BillingStreet , '(.*\r?\n.*){2,}'))
,
//Ignore this rule if the user has this flag active. Useful for bulk updating and don't have to worry about import errors.
$User.Bypass_Validation__c = False
)
This piece MID( $Setup.Global__c.CLRF__c ,3,1) represents a line break in Salesforce. Found out how it works from find line break in formula field. I would have liked to use Regex, but it just doesn't work if you ask me. Except for checking 2+ lines like in the above code.

Need Regular expression

I have tried a lot to write a regular expression for below line but could not get the success, so requesting some body to help me out in this.
Exp: "APStress_May-15---11.20.3_UIlog".
In the above example APStress and UIlog will be fix rest of the things will get change. i.e
Month ->May,
date -> 15,
Hour -> 11,
Minute ->20,
Seconds ->3
I am writing a script for analysis the logs for that i have to choose this particular file among others .
APStress.*UIlog. Here .* denotes any characters any number of times. Here is an useful link for your future reference. http://www.regex101.com/
Something like:
APStress_(.*?)-(\d{1,2})---(\d{1,2}).(\d{1,2}).(\d{1,2})_UIlog
(not necessarily the best way of doing it)
Try this:
APStress_([\w]+)-([\d]+)(-){3}([\d]{1,2}).([\d]{1,2}).([\d]{1})_UIlog
You could use named capture groups:
/^APStress_(?<Month>\w+)-(?<Date>\d{1,2})---(?<Hour>\d{1,2}).(?<Minute>\d{1,2}).(?<Seconds>\d{1,2})_UIlog$/
dump%+
outout:
("Hour", 11, "Month", "May", "Date", 15, "Seconds", 3, "Minute", 20)