Using the ignore-regex settings of Sublime SFTP plugin, which is set by default to :
"\\\.sublime-(project|workspace)", "sftp-config(-alt\\\d?)?\\\.json",
"sftp-settings\\\.json", "/venv/", "\\\.svn/", "\\\.hg/", "\\\.git/",
"\\\.bzr", "_darcs", "CVS", "\\\.DS_Store", "Thumbs\\\.db", "desktop\\\.ini"
How can I ignore folders with specific types of names, for example all folder which name is a digit ? Example: /54/ , /108/ etc.
This should do it -- RegEx and JSON require that backslashes be escaped, so we have to escape the backslash before the digits twice.
\\\d+
Related
I have filenames in format <pod-name>_<namespace-name>_<container-name>-<dockerid>.log
For example:
pod-name_namespace-name_container-name-7a1d0ed5675bdb365228d43f470fcee20af5c8bea84dd6d886b9bf837a9d358c.log
pod-name_namespace-name-1234567890_container-name-7a1d0ed5675bdb365228d43f470fcee20af5c8bea84dd6d886b9bf837a9d358c.log
Actually this is the k8s container's log files.
The namespace-name may contain numeric postfix that represents automation system run id (github.run_id - 10 digits number).
I need to parse filenames with regex to extract pod name, namespace name without run id, run id, container name and docker id.
Regex based on default fluentbit kubernetes parser that I need to change for our usage:
(?<pod_name>[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace_name>[^_]+)(-(?<run_id>\d{10,}))_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$
https://rubular.com/r/CROBxpHHgX5UZx
The regex above parses well filenames that contains namespace with run id, but fails to parse namespace without run id:
pod-name_namespace-name_container-name-7a1d0ed5675bdb365228d43f470fcee20af5c8bea84dd6d886b9bf837a9d358c.log
https://rubular.com/r/6MSQsnuGzrkVJG
In this case the run_id should be empty string
How to fix it that it match both cases?
You can use
(?<pod_name>[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace_name>[^_]+?)(-(?<run_id>\d{10,}))?_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$
See the regex demo.
The main point is to make two changes in (?<namespace_name>[^_]+)(-(?<run_id>\d{10,})) part:
make the [^_]+ pattern lazy, so that it could match as few chars other than _ as possibe, i.e. add a ? after +
make the (-(?<run_id>\d{10,})) part optional by adding a ? quantifier after the group.
I am using visual studio code to find and replace another part of the string.
The string will always contain the string "sitemap" without the quotes but i want to remove index.html
Some examples of what i need replaced:
front/index.htmltemplate.xsl
to
front/template.xsl
com/index.htmlwp-sitemap
to
com/wp-sitemap
Some my attempts on the vs studio code regex search box incude
sitemap[^"']*index.html
and
sitemap.*?(?=index.html)
but neither is identifying all of the strings that need replacing
This might do the trick for you: (index\.html)(?=.+(sitemap))
Explanation:
() = Group multiple tokens together to create a capture group
(index.html) = Create a capture group around your target string to replace
(?=.+(sitemap)) = Create a capture group for sitemap and allow for any type and number characters between sitemap and index.html until reaching "sitemap".
?= means this is a "positive lookahead" meaning it will match a group after the main expression without including it in the result. In this case it means it will match sitemap and any chars before it without including it in your result -- so you just get index.html.
https://regexr.com/6iipm
I would like to print a directory "w:\dir\xx.doc" as the output in my rmarkdown output pdf file.
I have tried to:
1) directly write in text:
here is the directory w:\dir\xx.doc
2) try to print it in inline R-code:
here is the directory r print("w:\dir\xx.doc")
Does anyone know how to print the directory?
My problem is not about how to treat a directory in R, but how to properly print out a directory in my pdf file as a string in a common fomat as a directory. So actually I do not want to functionally call the directory in R, but just to properly print it out. for instance I would like to have a sentence in my file: "here is the location where we store the file: w:\dir\xx.doc"
The backslashes are being interpreted as escape sequences.
The easiest solution is to use normalizePath() to convert the path to a more unix-like representation:
normalizePath(mydir, winslash = "/")
R on windows will interpret forward slashes correctly.
Alternatively you can try using a double-backslash (\) to escape your backslash, but there are usually several levels where this needs escaping.
In R, backslash must be escaped; so each time you want to write \ inside a string, you need to write \\.
mydir <- "w:\\dir\\xx.doc"
print(mydir)
# w:\\dir\\xx.doc
cat(mydir)
# w:\dir\xx.doc
I am using WordPress and the Search Regex plugin.
I need to covert several hundred Posts that contain a script which contains a unique Photo album number.
Each script needs to be changed to a shortcode which contains the same Photo album number.
Here is an example:
Search for the script:
<tt>%%wppa%%</tt> <tt>%%album=15%%</tt>
and replace it with the shortcode:
[wppa type="album" album="15"][/wppa]
What would I place in the Search field?
and
What would I place in the Replace field?
Use this regex:
<tt>%%([^%]+)%%</tt>\s*<tt>%%([^%=]+)=([^%=]+)%%</tt>
and this replacement:
[$1 type="$2" $2="$3"][/$1]
The $ numbers in the replacement refer to the capture groups: (). Overall, it's very simple, with [^%]+ matching "not %", \s* matching whitespace, and [^%=]+ matching "not % or =".
The plugin uses PCRE, but I'm not sure if the regex needs any adjustments since I don't use the plugin. (It may require escaping the / characters.)
I am writing a nginx conf file and I would like to match a path that specifies a portion that should be treated as a variable. Suppose the root for the requests is /foo and within foo there are randomly named folders such as /foo/abd /foo/lkd however every randomly named folder contains a static named folder /images. I would like my regex to designate that second part of the URL as a variable. Something like /foo/{{variable}}/images
To match /foo/{{variable}}/images where {{variable}} is a string having multiple characters from range a-z use following regex.
Regex: /\/foo\/([a-z]+)\/images/
Explanation: It matches multiple characters between /foo/ and /images
Regex101 Demo