I read that you should use ? to match text non-greedily, so the regex
http://.*?\.png
...used on
http://example.png.png
...would return http://example.png.
But the non-greediness only seems to work from left to right. That is, if I matched it on
http://http://example.png
...it would return http://http://example.png.
How can I get the code to match http://example.png only?
Try this:
http://[A-Za-z0-9_-]+\.png
It wont get the first http:// because it has more than [A-Za-z0-9_-]+ between it and .png
Could also use this if you are worried about other characters in the URL:
http://[^:]+?\.png
You could use a negative look ahead too, but I think smerny 's answer is better.
http://(?!http://).*?\.png
Related
How can I remove {color:#de350b} and {color} from:
{color:#de350b}FA_RDA_CORE-DEC-20220325122114-210-981{color}
to get:
FA_RDA_CORE-DEC-20220325122114-210-981
Good day.
Can you try this? Please don't forget substitution with "$5".
Regex101ttps://regex101.com/r/aDJzUf/1
I have been beating my head against the wall with this one. The url must contain \r\n at the end or the device I am connecting to will not recognise it. I did not create the device so I can't go in and change what it is looking for. I also can not use the percent values for them either. When I create the URL from a string the URL becomes nil because it does not like the \r\n. I have searched on here all day. Literally and have come up with nothing. If anyone has a suggestion please let me know. I would really appreciate it.
Edit.. The url is #"http://192.168.1.1/link.html?cmd=scan\r\n"
I was able to figure out another way in so I did not have to send the string like that. Thank for the help.
Try this:
NSLog(#"http://192.168.1.1/link.html?cmd=scan\\r\\n");
OutPut:
http://192.168.1.1/link.html?cmd=scan\r\n
You have to skip the "\" with just putting another "\".
Looking for some help here if anyone can offer some. I am working with an oracle database and I would like to trim a string up until a certain character '/'. These fields are paths of a URL and they are all different sizes so I need to make sure it's getting to the very last '/' in the URL and removing everything up until that point. Additionally, there is a session ID that is associated with some of these URLs that is located at the end of the string and has a semi-colon before it starts, so I would want to remove everything that contains a semi-colon up to the semi_colon and on. So essentially I want to remove content from the beginning of the URL and from the end of the URL if applicable. Examples of these URL's (string) are as follows:
Current URLS
/ingaccess/jsp/mslogon.jsp
/ingaccess/help/helpie_term_cash_surrender_value.html
/eportal/logout.do;jsessionid=xr8co1kyebrve47xsjwmzw--.p704
/eportal/logout.do;jsessionid=gdh_e_e1m1hna0z9ednklg--.p705
/ingaccess/help/helpie_term_northern_unit_value.html
/ingaccess/help/helpie_scheduled_rebalance.html
/eportal/home.action;jsessionid=9vhfbkhunkvtcm5g1dtgsa--.p704
/ingaccess/help/helpie_catch_up_50.html
/ingaccess/piechartmaker
/ingaccess/help/helpie_term_fund_balance.html
Desired URLS
mslogon.jsp
helpie_term_cash_surrender_value.html
logout.do
logout.do
helpie_term_northern_unit_value.html
helpie_scheduled_rebalance.html
home.action
helpie_catch_up_50.html
piechartmaker
helpie_term_fund_balance.html
Anyone know of an easy fix here? I've tried working with SUBSTR and REPLACE a bit but can't seem to get them to work.
Thanks a bunch in advance,
Ryan
Try this
SELECT CASE WHEN INSTR (surname,';')>0 THEN SUBSTR(surname,1
,INSTR(surname,';',1,1)-1) ELSE surname END FROM
(SELECT SUBSTR(column,INSTR(column,'/',-1)+1) AS surname
FROM tableName)
Tested on Apex
So you can have a test like this:
find(".blah").should have_content("blah blah")
But is there a way to just check if something is in blah?
find(".blah").should have_some_content
I do not believe there is a Capybara::RSpecMatchers for what you want. However, you could use the underlying Capybara::Node::Matchers.
Try:
find(".blah").has_no_text?.should be_true
If you really want to use the Capybara::RSpecMatchers, you could use have_content with a regex that looks for any non-whitespace character.
find(".blah").should have_content(/[^\s]/)
It looks like you are using Capybara.
Instead of the style in question, I will write it like this
page.should have_css('.bar', text: 'foo')
I would inspect the return value of find(".blah") and see what it is in the following two scenarios:
You know it's there, and something is returned
You know it's NOT there and something else (maybe nil?) is returned
Then writing the test just to confirm that, in your case, some elements with that class exist is easy. It's just a matter of knowing the difference between the return values of the .find method when there is and is not something found.
I'm using a route like this:
app.get( '/(aaa(?:&bbb)*)'
which should match
/aaa
/aaa&bbb
/aaa&bbb&bbb&bbb
but it's only matching
/aaabbb
I've removed the repeating modifier so it's only
app.get( '/(aaa(?:&bbb))'
but it's still only matching aaa&bbb and not matching aaa
I've been trying to google this but have been unable to find anyone else with the same problem.
Should I be escaping it someway?
Try escaping the /
'\/(aaa(?:&bbb)*)
I have tested this and have confirmed that it matches
/aaa
/aaa&bbb
/aaa&bbb&bbb&bbb