I have the following set of data :
(Name=[Jane Doe]>[Jane Doe]),
(Job=[Temporary Employee]>[Full Time]),
(Address=[1 place]>[2 St.]),
(Title=[Account Manager]>[Account Manager])
I am trying to find out which name-value pairs have been modified. For example,
While Name value stayed the same "Jane Doe" to "Jane Doe", Job's value was changed from "temporary employee" to "full time", Address' value was changed from "1 place" to "2 St.". Finally, title value remained the same.
All the comparisons will be done for values in [..] > [..]. I will also need what was changed, name, job, title and address.
Any help will be appreciated. Thanks
EDIT : Not sure why this was down voted. It is still a regex question where one needs to extract name, from-value and to-value pairs. Comparison will be done afterwards.
You can only match the keys and values - regex will not compare them for you:
\(([^=]+)=\[([^]]+)\]>\[([^]]+)\]\)
demo
Related
I wanted to use wild card search in DynamoDB with PHP.
I went through the AWS document but didn't find it. Help me please into this.
I have used filter expression like this:
'FilterExpression' => 'userId = :v1 and entryStamp between :v2 and :v3',
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html
ComparisonOperator
CONTAINS :
Checks for a subsequence, or value in a set.
AttributeValueList can contain only one AttributeValue element of type
String, Number, or Binary (not a set type). If the target attribute of
the comparison is of type String, then the operator checks for a
substring match. If the target attribute of the comparison is of type
Binary, then the operator looks for a subsequence of the target that
matches the input. If the target attribute of the comparison is a set
("SS", "NS", or "BS"), then the operator evaluates to true if it finds
an exact match with any member of the set. CONTAINS is supported for
lists: When evaluating "a CONTAINS b", "a" can be a list; however, "b"
cannot be a set, a map, or a list.
'FilterExpression' => 'userId CONTAINS :v1'
I am using Excel 2010 and currently trying to get a formula for my data using a Nested If And, but unable of the correct formula.
Here is some sample data to elaborate on my point:
(A1) Received Date (B1) DueDate
(A2) 7/1/2016 (B2) 7/8/2016
(A3) 7/1/2016 (B3) 6/29/2016
(A4) 7/1/2016 (B4) NULL
Basically, I want to create a formula that satisfies the following conditions. If Received Date < DueDate AND DueDate IS NOT NULL...then "YES", else "NO". So in this sample code above, only the first record should return "YES" and the other two should return "NO."
How do I do about a formula doing this?
I don't know how to do the second condition, the IS NOT NULL part. I put the cell numbers in parenthesis to simulate the table. (Hope that helps.)
Excel does not have a function to test for null. You can use IsBlank() to check for a blank cell or you can use IsNumber() to check for a numeric value. So, in your case something like
=if(and(isnumber(B2),A2<B2),"something","else")
Edit: If you want to check for the text "Null", then
=if(and(B2<>"Null",A2<B2),"something","else")
= is the "equals" comparison operator. "Not equals" is done with the <> comparison operator. Or you could do Not(B2="Null") but that's a bit too curly.
Another edit: FWIW, the first formula should still work, regardless of the cell containing text or being blank. As soon as the cell contains a date (which is a numeric value), the condition will be TRUE. So you can use that formula as well.
=IF(AND(B2<>"NULL",A2<B2),"YES","NO")
It looks like a simple task, but how would you solve it? I don't get any solution right now.
ls_message-text = 'Pernr. 12345678 (Pete Peterson) is valid (06/2015).
append ls_message to lt_message.
ls_message-text = 'Pernr. 12345678 (Pete Peterson) is valid (07/2015).
append ls_message to lt_message.
This is the code I got, the thing is, this is the message I am showing in my application. The customer says that the 2 messages are the same. The second should be deleted.
How would you compare it to delete the line? The table might contain more then 2 lines and also with another text like "is not valid".
I can't extend the structure to have more fields for comparison, I can only use the string comparison on this one field. Are there string comparisons possible with a regex or something?
Maybe you could solve your requirement using the Levenshtein distance . ABAP has a built-in function "distance" that gives you the number of operations to convert one string into another. Ex:
DATA msg1 type string.
DATA msg2 type string.
msg1 = 'Levehnstein Distance 7/2015'.
msg2 = 'Levehnstein Distance 6/2015'.
data l_distance type i.
l_distance = distance( val1 = msg1 val2 = msg2 ).
if l_distance lt 2 .
"It's almost the same text
endif.
In this case l_distance will be 1, because only one operation is necessary (replacing).
Hope this helps,
Assuming you want to retain only one message for each unique Pernr. in lt_message, you can use regex to filter for the Pernr. and use that as "key". Now you can delete all but the first message of lt_message that matches this key.
Expand your regex if you want to keep only certain messages, e.g. only the "is valid" ones.
have you tried looking to program DEMO_REGEX_TOY.
Gives an idea on how to work with Regular expresion, that probably will save the problem
This should be easy, but I'm finding it difficult.
I just want to find whether a substring exists anywhere in a string. In my case, whether the name of a website exists in the title of a product.
My code is like this:
#FindNoCase("Amazon.com", "Google Chromecast available at Amazon")#
The above returns a 0 which is correct because the entire substring "Amazon.com" doesn't exist in the main string. But some of it does, namely the "Amazon" part.
How could I achieve what I'm trying to do which is just see if ANY of the substring (at least more than 2 character in length) exists in the main string?
So I need something like FindOneOf() but actually "find at least three of". It should then look at the word "Amazon" in the product title and check if at least 3 characters in the sequence of "Amazon.com" exists. When it sees that "Ama" exists, then it just needs to return a true value. Can it be done using the existing built-in functions somehow?
Update: Very simple solution. I used Left("amazon", 3).
There's a lot of danger in false positives, like if someone was buying the Alabama state flag.
Because of store names that contain spaces, this is a little tricky (Wal Mart is often written with a space).
If your string always contains at [store], you can extract the store name by finding the last at in the sentence and creating a string by chopping off everything else.
Because it looks for occurrences of at only as a whole word, there's no danger with store names such as Beats Audio, or Sam's Meat Shop. I can't think of any any stores with the word at in the name. While that would technically trip it up, there's much lower risk, and you can do a pre-replace on such store names.
<cfset mystring = "Google Chromecast available at Amazon">
<cfset SellerName = REReplaceNoCase(mystring,".*\b(?:at)\b(?!.*\b(?:at)\b)\s*","")>
<cfoutput>Seller: #Sellername#</cfoutput>
You can then do your comparisons much more safely.
Per your comment, If you know all possible patterns, you can still obtain the data if you want to (false positives can either be embarrassing or catastrophic, depending on the action). If you know the stores you're working with, you can use a regex to pull out the string like this
<cfset mystring = "Google Chromecast available at Amazon.co.uk">
<cfset SellerName = REReplaceNoCase(mystring,".*\b((Google|Amazon|Wal[\W]*Mart|E[\W]*bay)(\.[a-z]+)*)\b","\1")>
<cfoutput>Seller: #Sellername#</cfoutput>
The only part you need to update is the pipe-delimited list You might add K-Mart as K[\W]*Mart the [\W]* permits any special character or space so it covers kMart, K-Mart, k*Mart, but not Kwik-E-Mart.
Update #2, per more comments
<cfset mystring = "Google Chromecast available at Toys-R-US">
<cfset SellerNameRE = REReplace(rsProduct.sellername,"[\W]+","[\W]*","ALL")>
<cfset TheSellerName = REReplaceNoCase(mystring,".*\b((#sellernameRE#)(\.[a-z]+)*)\b","\1")>
<cfoutput>Seller: #TheSellername# (#SellerNameRE#)</cfoutput>
This replaces any symbols with the wildcard character so that symbols aren't required so that if something says Wal*Mart, it will still match WalMart.
You could also load a seperate column with "Regex Names" so that you're not doing this each time.
So your table would look something like
SellerID SellerName RegexName
1 Wal-Mart Wal[\W]*Mart
2 Toys-R-US Toys[\W]*R[\W]*US
<cfset mystring = "Google Chromecast available at Toys-R-US">
<cfset TheSellerName = REReplaceNoCase(mystring,".*\b((#rsProduct.RegexName#)(\.[a-z]+)*)\b","\1")>
<cfoutput>Seller: #TheSellername# (#SellerNameRE#)</cfoutput>
Solved it by doing this
#FindNoCase(left("Amazon.com", 3), "Google Chromecast available at Amazon")#
Yes there is potential it won't do what I need in cases where the seller name less than 3 characters long. But I think its rare enough to be ok.
I am looking for a regular-expression which can be used to check a postal address field value, with minimum length of 10, containing numbers, and characters as well:
Currently I use this expression:
`\\[a-zA-Z]|\d|.|\s{10,}`
The environment is:
lotus xpages, and the regular expression is stored in properties file within the application design.
<xp:inputText id="address" dojoType="dijit.form.ValidationTextBox" value="#{complaintDocument.address}">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="promptMessage">
<xp:this.value><![CDATA[${javascript:clientData['address']}]]></xp:this.value>
</xp:dojoAttribute>
<xp:dojoAttribute name="placeHolder">
<xp:this.value><![CDATA[${javascript:common['textValueMinimumTenCharacters']}]]></xp:this.value>
</xp:dojoAttribute>
<xp:dojoAttribute name="trim" value="true">
</xp:dojoAttribute>
<xp:dojoAttribute name="regExp">
<xp:this.value><![CDATA[#{javascript:regExp['minimumTenCharacters']}]]></xp:this.value>
</xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:inputText>
Is there any wat to make the regular expression for this purpose more simple?
I dont thinkt that your regex can be any simpler. Maybe you could use
.{10} > any character, max 10 length
If you want to check if a zipcode is valid you can make a java class that is used to check if the zipcode that was filled in is correct. This class can be a stored in the application scope
<faces-config>
<managed-bean-name>
yourzipcodeclass</managed-bean-name>
<managed-bean-scope>
application</managed-bean-scope>
<managed-bean-class>yourclass</managed-bean-class>
</faces-config>
</faces-config>
Anyways When you want to check if a value is a valid zipcode you should add a method to this class isValidZipCode(String code, String country)
in this method you check depending on the country you have given if the zipcode is correct. How you check it is up to you. You can use a regex for every country or you can use a webservice, or a lookup in a database etc.
You can use this method in a custom validator.