Get last field using awk substr

Use the fact that awk splits the lines in fields based on a field separator, that you can define. Hence, defining the field separator to / you can say: awk -F “https://stackoverflow.com/” ‘{print $NF}’ input as NF refers to the number of fields of the current record, printing $NF means printing the last one. So … Read more

Extract a substring according to a pattern

Here are a few ways: 1) sub sub(“.*:”, “”, string) ## [1] “E001” “E002” “E003” 2) strsplit sapply(strsplit(string, “:”), “[“, 2) ## [1] “E001” “E002” “E003” 3) read.table read.table(text = string, sep = “:”, as.is = TRUE)$V2 ## [1] “E001” “E002” “E003” 4) substring This assumes second portion always starts at 4th character (which is … Read more

What is the difference between String.slice and String.substring?

slice() works like substring() with a few different behaviors. Syntax: string.slice(start, stop); Syntax: string.substring(start, stop); What they have in common: If start equals stop: returns an empty string If stop is omitted: extracts characters to the end of the string If either argument is greater than the string’s length, the string’s length will be used … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)