Regular Expression for text in between tags - qstring

I have a QString that I need to parse. This QString is a QNetworkReply object obtained from an URL.
<label id='Today_LastSale1'>$ 21.2401</label>
I need the value 21.2401 from the QString.
I am tried this.
QRegExp rx("<label id='Today_LastSale1'>$ (\\d)</label>");
But it returns -1. Need help with this.
Thanks in Advance!

You can just try to remove the non-numeric and "." characters from your string. Try regex replace with this expression: "[^0-9\.]"
Code
QRegExp rx("[^0-9\\.]");
yourString.replace(rx, "");

Related

Replacing GUID in Kusto

How can I replace all GUID's in a Kusto query with no value.
e.g.
my data looks like
/page/1d58e797-a905-403f-ebd9-27ccf3f1d2cd/user/4d58e797-a905-403f-ebd9-27ccf3f1d2c3
and I want
/page//user/
You can use the replace function. Also, you can test regular expression here.
let input = '/page/1d58e797-a905-403f-ebd9-27ccf3f1d2cd/user/4d58e797-a905-403f-ebd9-27ccf3f1d2c3';
let rx = '[({]?[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}[})]?';
print replace(rx, '', input);
Try using the below regex It will remove guid (8-4-4-4-12) in url
let regex =/(\/[\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})(\b|\/)/g

typo3 extension formhandler pregmatch

I am trying to validate a iban no for germany, but I cannot get pregMatch to work with formhandler. I cannot find a mistake and compared it with the formhandler documentation, but nothing helped. Maybe somebody has a hint for me.
This is my code:
debitiban.errorCheck {
1 = pregMatch
1.value = ^DE\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$
}
The value is directly passed on to PHPs preg_match function, so it has to be a valid PCRE regex pattern. You are missing a delimiter charater in your expression. Try to surround the expression by slashes:
debitiban.errorCheck {
1 = pregMatch
1.value = /^DE\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/
}

Extract the "value= " from my response code using the following xpath query

I have the following response :
input id=\"order_id\" name=\"order[id]\" type=\"hidden\" value=\"42307\" "
And I want to get in Jmeter the value of :
value=\"42307\"
And I am using the xpath extractor query :
//input[#id='order_id']/value
But it fails to get the value.
I found the correct regexp. it's just 'value=(.+?)', the only left problem is that it returns \"42307\" and I need just 42307 .
First I think you mean regex. Xpath doesn't make any sense unless you're talking about searching an XML document.
The regex to get the value of the value field would be this assuming it will always be an integer:
value=[\\"]?(\d+)[\\"]?
If it can be any ASCII character, then you would replace the \d with a . (period):
value=[\\"]?(.+)[\\"]?

Ruby: replace a given URL in an HTML string

In Ruby, I want to replace a given URL in an HTML string.
Here is my unsuccessful attempt:
escaped_url = url.gsub(/\//,"\/").gsub(/\./,"\.").gsub(/\?/,"\?")
path_regexp = Regexp.new(escaped_url)
html.gsub!(path_regexp, new_url)
Note: url is actually a Google Chart request URL I wrote, which will not have more special characters than /?|.=%:
The gsub method can take a string or a Regexp as its first argument, same goes for gsub!. For example:
>> 'here is some ..text.. xxtextxx'.gsub('..text..', 'pancakes')
=> "here is some pancakes xxtextxx"
So you don't need to bother with a regex or escaping at all, just do a straight string replacement:
html.gsub!(url, new_url)
Or better, use an HTML parser to find the particular node you're looking for and do a simple attribute assignment.
I think you're looking for something like:
path_regexp = Regexp.new(Regexp.escape(url))

Ruby, delete null values of a string

Example:
String test="hi\000\000\000"
Problem:
Some methods require a string to be without nulls, how can I delete all null values of a string?
.split("\000",1) gives me an error: 'force_encoding' method doesn't exist
.gsub('\000','') does nothing
Even more simple:
test.delete("\000")
Try using double quotes, so test.gsub("\000", '').
Right now I tried this in JRuby and it worked:
test.gsub(/\000/, '')
Note that I am using a regex in the gsub and not a string.

Resources