Regular expression for date in selenium ide - selenium

I tried to create a regular expression for the below date format, where as I am unable to justify that, please help me out.
04-Apr-2013 [10:58:13 GMT+05:30]
This is what I came up with:
\\d{2}-\\w{3}-d{4} [\\d{2}:d{2}:d{2} \\w{3}+\\d{2}:d{2}]
Correct me where i have gone wrong.
Thanks

You have to escape the square brackets as they have a special meaning in regular expressions and also some of your digit indicators doesn't have backslash prefix. I've tested the following regex and it worked for me:
regexp:\d{2}-\w{3}-\d{4} \[\d{2}:\d{2}:\d{2} \w{3}\+\d{2}:\d{2}\]

Related

Regexp - recognize trailing 0 for decimal numbers?

I need a regular expression which can find a trail of "0" in the decimal space.
F.e. following format should be recognized:
1.0
1.00
1.000
etc...
Is there somekind of "wildcard" for that?
Any idea?
Thanks,
KS
Please see the following regular expression that matches trailing zeros on the end of any decimal. Note that this does match trailing zeros in the case where there is a meaningful decimal value, but zeros occur after.
https://regex101.com/r/BJvLrO/1/
When working with regex, it is very valuable to always use a tool like https://regex101.com or https://regexr.com. Both of these tools will help you truly understand the Regular Expression. Try hovering your mouse over the different elements of the regex in my example and the tool will describe each part. You can also read the "Explanation" section to on the right side.

BigQuery - Illegal Escape Sequence at REGEXP_REPLACE

I'm having an issue matching regular expression in BigQuery.
REGEXP_REPLACE(tc.metadata->>'document_number', '\D', '', 'g') = m.document_number
However, BigQuery doesn't seem to like escape sequences for some reason and I get this error that I can't figure out:
Syntax error: Illegal escape sequence: \D
This code works fine, but BigQuery is unhappy with it and I can't figure out why. Thanks in advance for the help
You need to double escape the the character in BigQuery, as the first / will be consumed by JavaScript.
Try double escaping, e.g. \\D and that should work for you.
In [1] if you scroll down you can see the escaping sequences of standard SQL and none is \D, so as Ben P says, you need to double escape to have the backslash escaping sequence. I assume it's what is missing but if you could elaborate further your question the answer would be indeed more accurate.
[1] https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#string_and_bytes_literals

What's the regular expression to replace (., space, -, ) in a string using Labview

I am trying to replace some unnecessary characters in a string in LabView. For example in the following string, "he llo-hOW-are.You?" I want to replace space, . and - with an Underscore _.
The output shall be "he_llo_hoW_are_You?"
I tried "[\ \.\-]" and many more things but nothing seem to work for a regular expression.
I am using Search and Replace function and I am putting the Regular expression in the Search String field.
Thanks.
Did you make sure to right click the function and check the Regular Expression option? The function won't work with regexes otherwise (as the help for it says).
This seems to work just fine here:
Make sure you set the Regular Expression in the "Search and Replace String" right click menu.
It should work with the regular expression you are trying to use. Or you can use [\ .-] in the Regex as well.
This logic will apply all special Characters.

Objective C parse string for middle chars

This is a bit of a puzzler for me. I have a string that looks like:
fanspd<fanspd>3</fanspd>
doorinprocess<doorinprocess>0</doorinprocess>
timeremaining<timeremaining>0</timeremaining>
macaddr<macaddr>60:CB:FB:99:99:C1</macaddr>
ipaddr<ipaddr>10.0.0.6</ipaddr>
model<model>4.4eWHF</model>
softver: <softver>2.14.2</softver>
interlock1: <interlock1>0</interlock1>
interlock2: <interlock2>0</interlock2>
cfm: <cfm>2200</cfm>
power: <power>120</power>
inside: <house_temp>-99</house_temp>
<DNS1>10.0.0.1</DNS1>
attic: <attic_temp>76</attic_temp>
OA: <oa_temp>-99</oa_temp>
server response: <server_response>Ó£àêEE²ç©þ]kõ «jsÐ</server_response>
DIP Switches: <DIPS>11100</DIPS>
Remote Switch: <switch2>1111</switch2>
Setpoint:<Setpoint>0</Setpoint>
The string includes the "/n" so I have split it into corrisponding lines that look like
fanspd<fanspd>0</fanspd>
All I really want is the char(s) in the middle of the line. In the above example it would be 0.
I can match everything with regular expressions but by doing the following:
(.*)(<[a-z]+>)(.*)(</[a-z]+>)
But what I'd like is something more that would exclude or strip away or remove all the junk and grab the middle chars.
(!(.*)(!<[a-z]+>))(.*)(!(</[a-z]+>))
I've tried this and it does not work. I've also thought of doing another [NSstring componentsSeparatedByString:#"(with either < or or >"] but that would leave be with more parsing yet to do and I think there should be a way to get just the chars inbetween the tags with either regular expressions or string compare or some such way to parse out the
Any suggestions or help would be greatly appreciated.
Thanks
Two things.
Your regular expression does not escape the forward slash.
Your regular expression seems overly complicated for what you are trying to do.
If all you want is that lone middle character with regular expressions,
Try this:
<[a-z]+>(.*)<\/[a-z]+>
Here's a great tool to play around with:
http://rubular.com
Heck you could probably even get away with:
<[a-z]+>(.*)<\/
EDIT:
I figured out your problem partially, some of the tags part way down contain characters other than a through z. So here you go:
<.+>(.*)<\/.+>

Write regex for pattern like W00001

I am new to Regular Expressions and any help is highly appreciated.
Pattern like W00000,W00001,W00002,W00004
Must begin with W
Each string before comma must be six characters
String can only be repeated four times
Comma in between
Must not begin or end with comma
I tried below pattern and some others, like (^[W]{1}\d{5}){1,4}'), and none of them work correctly:
Select 'X' from dual Where REGEXP_LIKE ('W12342','(^[W]{1}\d{5})(?<!,)$')
My understanding is that the OP is saying the match should fail if the string begins or ends with a comma, not just that the preceding or trailing commas shouldn't match, so anchors are needed. Also, based on the regex he attempted, I infer that a single group, such as W00000, should match. So, I think the regex should be this, if the characters following the W must always be digits:
^W[:digit:]{5}(,W[:digit:]{5}){0,3}$
Or this, if they can be something other than digits:
^W[^,]{5}(,W[^,]{5}){0,3}$
UPDATE:
The OP posted the following comment:
I am on Oracle 11g and [:digit:] doesn't work. When I replace it with [0-9] it then works fine.
According to the documentation, Oracle 11g conforms to the POSIX regex standard and should be able to use POSIX character classes such as [:digit:]. However, I noticed in the docs that Oracle 11g does support Perl-style backslash character class abbreviations, which I didn't think was the case when I originally wrote this answer. In that case, the following should work:
^W\d{5}(,W\d{5}){0,3}$
Well in that case, you can do this:
(W[^,]{5},){3}W[^,]{5}
If I understood correctly, this should do it!
^W[0-9]{5}(,W[0-9]{5}){0,3}$
One W12345 pattern, maybe followed by one to 3 ,W12345 blocks.
Edit1: Adding ^$ to fail if there is a comma
Edit2: Fix class, since it fails on Oracle 11g