extract value from the url by using a regex - coldfusion

I have this string value
var x = '/index.cfm?act=page1.showdata';
want to extract page1
if i had to use it as simple, i am use contains to find it and make it work, but i really want to use regex to find that value and put it into a variable,
using coldfusion

No need for regex. Every query string parameter is available in the url scope. They're all already variables.
<cfdump var="#url#">
This dumps a struct whose keys are the parameters.
So the CF variable url.act has a value (string) of page1.showdata.
What else do you need than that?

Related

what will be the regular expression of highlighted values?

{"id":"mergeresult:68b2a5f3-f22a-40c7-b6d0-728ca3f4ede2:2020-06-25:fd18a85c-a1a8-40ae-859a-465b6b9b13a8","mailMergeId":"1636afe5-d103-45d1-8786-d13022d92e07"}
This is the response I a m getting from api and I want this 1636afe5-d103-45d1-8786-d13022d92e07 in my output variable without quotes and also mergeresult:68b2a5f3-f22a-40c7-b6d0-728ca3f4ede2:2020-06-25:fd18a85c-a1a8-40ae-859a-465b6b9b13a8
so basically I want id and mailMergeId value without quotes so that I can pass it into next api request
This is for your id of type 8-4-4-4-12
[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}

Save substring from field to copyfield using regex in Solr

I'm importing data from mysql table using import handler. I have a column msg, of type text. Using regex, I have to save substring in a copy field.
msg: 94eb2c0cb17ef354bb052c57f40c\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding pnr:986|0978325
Expected Solr result:
{
"msg_body": "94eb2c0cb17ef354bb052c57f40c\\r\\nContent-Type: text/plain; charset=UTF-8\\r\\nContent-Transfer-Encoding pnr:986-0978325",
"pnr_number": "pnr:986-0978325"
}
My REGEX:
(pnr|(P|p)[ _.:,!"'-/$](N|n)[ _.:,!"'-/$](R|r))+[ _.:,!"'-/$]+[0-9]{3}[ _.:,!"'-/$]+[0-9]{7}
Please help me out as i'm new to solr
You'll need to define a custom field for pnr_number.
Use a copyField to copy msg_body to pnr_number
In the custom field definition, use
<filter class="solr.PatternCaptureGroupFilterFactory" pattern="regex goes here" preserve_original="false"/>
Since you are using Data Import Handler, you have 3 options:
Use a Regex Transformer in DIH definition.
Use a RegexReplaceProcessorFactory Update Request Processor (in solrconfig.xml).
Use a Regex filter in the analyzer chain
With the first two options, the regex will extract the pattern before the field is actually indexed. In the last option, the stored representation (if you store the field) will contain the original full string, but the indexed (searchable) representation will contain regex match.

capybara find and save text value from a page

i am in the process of writing a Capybara Automation suite. one thing that i am trying to do is extract a value between the td tags from the html source
<td class="table-column-data">CB/AE9999XX/A001</td>
i.e. find and extract the value CB/AE9999XX/A001 then save it into a variable to use later on.
i hope you can help
thanks
saved_text = find("td.table-column-data").text
Will get the text from the element - obviously the selector passed needs to select a unique element, which will depend on the surrounding html
You can use the below mentioned way to extract and save the value in a variable:
extractedValue = find('.table-column-data').text
This will fetch the text "CB/AE9999XX/A001" and store it in the variable "extractedValue".
Apart from this, you can also extract the text using jquery as shown below:
extractedValue = page.evaluate_script("$('.table-column-data').text()")
Hope this helps :)

In querying a collection in a Mongo database with Mongoose, how can I find where a value is LIKE a query term?

I've search hard for an answer to this but haven't found anything that works. I have a NodeJS app, with the Mongoose ORM. I'm trying to query my Mongo database where a result is LIKE the query.
I have tried using a new RegExp to find the results, but it hasn't worked for me. The only time I get a result is when the query is exactly the same as the collection property's value.
Here's what I'm using right now:
var query = "Some Query String.";
var q = new RegExp('^/.*'+ query +'.*/i$');
Quote.find({author: q}, function(err, doc){
cb(doc);
});
If the value of an author property contains something LIKE the query (for instance: 'some. query String'), I need to return the results. Perhaps stripping case, and excluding special characters is all I can do? What is the best way to do this? My RegEx in this example is obviously not working. Thanks!
You likely want to create your RegExp as follows instead as you don't include the / chars when using new RegExp:
var q = new RegExp(query, 'i');
I don't know of a way to ignore periods in the author properties of your docs with a RegExp though. You may want to look at $text queries for more flexible searching like that.

How do I search a db field for a the string after a "#" and add it to another db field in django

I want to have a content entry block. When a user types #word or #blah in a field, I want efficiently search that field and add the string right after the "#" to a different field as a n entry in a different table. Like what Twitter does. This would allow a user to sort by that string later.
I believe that I would do this as a part of the save method on the model, but I'm not sure. AND, if the #blah already exists, than the content would belong to that "blah"
Can anyone suggest samples of how to do this? This is a little beyond what I'm able to figure out on my own.
Thanks!
You can use regex (re) during save() or whenever to check if your field text contains #(?P<blah>\w+) , extract your blah and and use it for whatever you want .