Problem:
I have a list of fields, List {"CustomerID", "Amount", "order id"}. Need to extract the values from below text
Sample Text 1:
CustomerID: B377JWIWV10LEX
Amount: Rs.1500
order id : 604-1343456290402730
Reason: Customer tried making a payment for 1500 via UPI
Sample Text 2:
CustomerID : B377JWIWV10LEX
AmOunt: 1500
order id : 604-1343456290402730 424
Reason: Customer tried making a payment for 1500 via UPI
Sample Text 3:
CustomerID # B377JWIWV10LEX
AmOunt: 1500
order id : 6041343456290402730424
Reason: Customer tried making a payment for 1500 via UPI
Tried the below Regex:
"(?<="+ valueInList +"\s*(No|#|id|:|-|\s)\s(Rs.|Rs|Rs\s*.))(.)(?!\n)"
Not getting the exact value.
Regex tested in : https://regex101.com/r/xdK4St/1
You have to create a regex for each field you want to extract. For example, for customer id we have (CustomerID)\s*[:#]\s*(\w+). Here, (\w+) will match the actual id. Similar for the amount: (amount)\s*:\s*(rs\.)?(\d+) where (\d+) is the amount. Note that the regexes should be made case-insensitive.
Related
Okay so my question is two parts:
I retrieve from a webservice about 10 relevant IDs and Names based on the given parameter. Is their a way to convert the response into some list?
The response is like :
ID1:XXX - Name1: test1 - Address1: Narnia - Gender1: M
ID2:YYY - Name2: test2 - Address2: Hogwarts - Gender2: NA
The second part:
How do I fill in a gridview from the retrieved list above? And have like certain conditioning like if Address is Hogwarts I'd have an extra column (ex: Desc: ) Where you fill it in your house name or if the house Address is N\A then the Desc column becomes mandatory to be filled in.
I am trying to achieve the following scenario...
Within my elasticsearch index will be a number of specific records that i want to be the number 1 result if the query contains specific words within this field. This field is company name so for example if someone puts 'ford' into the search the company name field will have a boost over all other fields so this is highest score..... this seems to work for me with the single word... ford, nissan etc...
however... if the query is say 'ford car sales' then other pages are ranked higher than the one i want because of course many pages contain all these terms (the search operator is AND)... but is there a way to still rank my page top by being able to boost words in the company name field irrespective of how many words are in the query or found elsewhere.....
finally could i somehow set up variations of company names to the one in the field to boost these results... so where name is fiat-chrysler, set up other variations a user may search on such as 'fiat chrysler' without the hyphen....
thanks for any help....
In your query when you use "field" to specify the fields you are searching in, add boosting to 'company name' field by using ^.
Example:
{
"fields": ["company_name^10","other_field_a", "other_field_b"],
"query" : {
"term" : { "company_name" : "ford" }
}
}
I hava a database which only have 2 table Object , User ,
Obviously user table has information about all user and the object table have millions of records
ObjectTable
Id (int)
Text1 (nvarchar(max))
Text2 (nvarchar(max))
I am trying to make a translator , first of all i put all data in database like following
1 : Good , Well
2 : Bad , NotWell
3 : Man , Husband Of Women
if suppose i havae 2 text boxes in my site user enter following text
Good Bad Man
then i will split that string on space and then i will have an array of string now i will took first element of array and go to server to find that wheather there is any match of Good in my database if i found match then i will replace that value with that Text2 like we have Well for Good which took too much time to translate and sometime it gives Request Timed Out . So , what is the best way to deal with it
You do not provide a lot of information to help you about your timeout problem.
Only things I can tell you are :
first of all, check that there are indexes on your Text1 and Text2 columns. If not, add it
look at your sql query. It should be SELECT * FROM OBJECT WHERE TEXT1='Good' (maybe add a top 100 to avoid returning to many things with LIKE ).
For the index to run smoothly, there should be no function called on column TEXT1 (like uppercase or trim). If you use a like, it should be TEXT1 LIKE 'good%' (% at the end)
if you use a like, beware of not returning your whole table on a empty entry, % or _ entry ( LIKE '%', LIKE '%%', LIKE '_%' can be bad things)
why use nvarchar(max) if you are just storing words ?
don't forget to sanitize your entries to avoid sql injection
Is this possible to do by using only the one name column in the database ?
Say I have the following value in the name field of my products table:
Samsung Blu-Ray Writer
When the html renders in the view I am going to parse the string and replace all the spaces with
hyphens and remove all capitals, so it will look like so: samsung-blu-ray-writer
When this product link is clicked it will send to the server a request to get
the product by the name of samsung-blu-ray-writer. Of course in the database
the product name is Samsung Blu-Ray writer. So when I create the query I will of course
need to replace all the hyphens with spaces again but this will also remove the required "-" in Blu-Ray.
I understand I can just use two fields, say ProductName and DisplayName. But this seems like
a waste and hopefully there's an easy solution to this.
Even if initially save all product names as hyphenated then I would still loose the
hyphens that were meant to be in the actual product name when I parse the string to replace them with spaces for display purposes.
You don't need to replace the hyphens with spaces on the second trip. Look at how Stack Overflow does it. Put the ID in the URL before the product name, then look up the product by ID on the return trip. By doing it this way, it doesn't matter how you formatted the product name in the URL - it's just for display purposes.
i have project in ASP.NET MVC 3 and a mysql database that contains a table of string values for phone numbers (this phone numbers can be stored as 123 456-789 or 12345 6789 or 123456789 or any ways the user enter his number) and other table with a keywords data for that users.
The thing is that i have a search that will find in the keywords table (fulltext table) for the users, but i'm writing a method that search in the phone table if the search query matches against certain regular expression.
I have 2 questions:
- How could be that regular expression from the C# code side that tells what method to execute (SearchByKeyword or SearchByNumber)?
- Using the same regular expression i think, i must do the mysql query to search in the phones table... how can i do it?
I hope i have explained well and sorry if my english is a little bit bad.
It's best when you capture the data to standardise the format it is saved in, IE:
111-111-1-111-11
1111-1111-1111
111111111111
1-1-1-1-1-1-1-1-1-1-1-1
All will save as
111111111111
You can then do a simple LIKE query:
SELECT * FROM tblNumbers WHERE number LIKE '%111%'
I would say that its bad idea to feed a phone number from the input -> directly to query variable.
better way would be:
input -> parser, error check procedure -> MySQL query request.
and before adding your phone number to the query - you can remove all extra symbols, like (, ), -, "space", etc.