Jump to content

RuleBritannia

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by RuleBritannia

  1. Hello I seem to have tried many combinations to get this process to run in the background, but it doesnt. shell_exec('C:\ffmpeg -y -i "C:\2.avi" -preset veryslow -crf 25 "C:\2.mkv" 1>output.log 2>error.log &'); Tried to redirect error to error.log, output to output.log, and & to run in the background, This does not work because the php script waits for it to finish. I have tried many variations of this code(swapping locations of 1< 2<, removing "1" from 1<) etc Also tried this shell_exec('C:\ffmpeg -y -i "C:\2.avi" -preset veryslow -crf 25 "C:\2.mkv" <input.log 1>output.log 2>error.log &'); this should direct input to a input.log file, But this causes the whole script to not even work. Anybody had any experience with this function? Thanks in advance
  2. The string is actually a link, example http://000000000.this-is-another-version-new.com OR http://111111111.this-is-another-version-old.com So strpos would just result in a link that doesnt work.(more factors than just the old|new in the overall match) The reason this would have to be done within the regex is so that it sees both matches within the whole string, but chooses correctly which string to return(based on the look variable) I will post the full story/regex soon, just doing another task right now. Thanks for your time
  3. But using strpos and if would mean pasteing the regex twice with just slightly edited parameters?, This method is easily do-able and can solve the problem right now, But I was just curios if there was a better way of doing it. I can post the full regex/story if needed, but id have to prepare quite alot of data, which is why I didnt already do it.
  4. So I currenty have a working regex for my needs. However a problem has occured. (page consisting of lots of strings) $s1 = 'this is the other version new'; $s2 = 'this is the other version old'; $look = 'new'; My regex currently matches most of the string, followed by the look variable, so it matches the $s1 without going to the lengths of rewriting the regex(its actually more complex than this, im just trying to simplify for whoever reads this) is there a way to provide the variable $look, with a string, that is processed by the regex as NOT find this string. A non-working theoretical example $look = [^n][^e][^w] my wishfull returned match would this time around be $s2 Thanks in advance.
  5. Hello Josh I see my first result was not correct, I reedited the script to run diff results to post so you could see, seems i ran the result without the () around .* , my fault. It seems you have found the answer I was looking for all along. preg_match('~(I HAVE HAD ENOUGH)(?:.*?(THIS HEADACHE))?~','I HAVE HAD ENOUGH OF THIS HEADACHE OK',$m); var_dump($m); This is working correctly, THANKS ALOT! 9 hours working on this now. When I get paid I will try to send a donation to the first link in ur sig. Thanks Requinix also for the help + previuos correct answer. :happy-04:
  6. Hello Josh Thanks again for your detailed explanation, But it doesnt work for this example I gave here. In this thread, I noted at the top that I apended the string from the previuos post, Your working example only works for the previuos example, Not this example Current example 'I HAVE HAD ENOUGH OF THIS HEADACHE OK'; We want 'I HAVE HAD ENOUGH' and if its there 'THIS HEADACHE' So lets apply your method preg_match('~(I HAVE HAD ENOUGH)(.*?)(THIS HEADACHE)?$~','I HAVE HAD ENOUGH OF THIS HEADACHE OK',$m); var_dump($m); Now, when we run this, it will return array(2) { [0]=> string(37) "I HAVE HAD ENOUGH OF THIS HEADACHE OK" [1]=> string(17) "I HAVE HAD ENOUGH" the match does not display 'THIS HEADACHE' subgroup. But if we do this. preg_match('~(I HAVE HAD ENOUGH).*?(THIS HEADACHE)~','I HAVE HAD ENOUGH OF THIS HEADACHE OK',$m); Dont give this subgroup the option to pick and choose what it wants to return, removed ?, so we want that group. Also had to remove $ to match main result. This returns. array(3) { [0]=> string(34) "I HAVE HAD ENOUGH OF THIS HEADACHE" [1]=> string(17) "I HAVE HAD ENOUGH" [2]=> string(13) "THIS HEADACHE" } This result here is correct, But the regex is not, But the subgroup 'THIS HEADACHE' must only return if its there, But ofc, when we give it this option, when the subgroup is there, it will not be returned in the result, so we wont know if it was there or it wasnt(unless we do other string search and manipulation which should'nt have to be done) Sorry If I have not made full sense here, Been working on this pattern for over 8 hours now. Thanks
  7. I seem to have found one unpractical way of doing it, completly against code brevity $string = 'I HAVE HAD ENOUGH OF THIS HEAACHE OK'; preg_match("/((I HAVE HAD ENOUGH).*?(THIS HEADACHE))|((I HAVE HAD ENOUGH).*?(THIS HEADACHE)?)/i",$string,$match); echo '<pre>'; var_dump($match); echo '</pre>'; This will return the (THIS HEADACHE) in the match first if its there. result array(4) { [0]=> string(34) "I HAVE HAD ENOUGH OF THIS HEADACHE" [1]=> string(34) "I HAVE HAD ENOUGH OF THIS HEADACHE" [2]=> string(17) "I HAVE HAD ENOUGH" [3]=> string(13) "THIS HEADACHE" } Or, If the subgroup doesnt match, the OR statement checks the whole main group again with the ? parameter at the last sub group, happily accepting nothing result array(6) { [0]=> string(17) "I HAVE HAD ENOUGH" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(17) "I HAVE HAD ENOUGH" [5]=> string(17) "I HAVE HAD ENOUGH" } There must be a correct way to do this, surely this way is not the msot pleasent way to acheive such a small thing. Thanks in advance
  8. Hello Thanks for the in depth replies both of you, However what you have posted I seem to have comprehended already, Apart from the U modifier. I must be doing something the wrong way. Here is my example, which either of you may remember from the previuos post, but this time I have just appended one word. $string = 'I HAVE HAD ENOUGH THIS HEADACHE OK'; preg_match("/(I HAVE HAD ENOUGH).*?(THIS HEADACHE)?/i",$string,$match); echo '<pre>'; var_dump($match); echo '</pre>'; match will consist of array(2) { [0]=> string(17) "I HAVE HAD ENOUGH" [1]=> string(17) "I HAVE HAD ENOUGH" } The regex seems to see that because (THIS HEADACHE)? is optional, It is happy to accept nothing before checking, OR, if I am wrong, and it IS checking (THIS HEADACHE), if it finds a match, it will not return it in the results, So this is why I came to my conclusion of its happy with nothing over something, If however I remove the ? after (THIS HEADACHE)?, The match is correct. array(3) { [0]=> string(32) "I HAVE HAD ENOUGH THIS HEADACHE" [1]=> string(17) "I HAVE HAD ENOUGH" [2]=> string(13) "THIS HEADACHE" } Adding the optional ? to the group says if its there, find it but dont bother returning it who cards, if its not there then nothing to return anyway who cares. I cant understand why it would work like this Im also now going to re-read your post josh as its so in depth. Thanks in advance
  9. In the order of match something, then nothing, I know '?' will check for nothing or something, But using this it will accept the first match being nothing, so it wont bother to match something after, If I can actually match something before, then nothing after, something will be included in the result.? Other explanation 1st match = finish bothering ? = this will accept in order of nothing, then something (match : nothing) +? = this will accept in order something, but NOT nothing (match : fail) *? = this will accept in order nothing, then something (match : nothing) Overall, something is never checked to even bother a return, as the regex is happy with nothing. How is this even possible to acheive?
  10. Yes, this is exactly how I understood it to be after your 1st post, but my later explaining was incorrect when i said 0 or more, I should have wrote nothing and more. It seems also that, whilst using start and end delimiters here, it works on this test question, but on my overall problem this doesnt work on , I think im going to bed, thanks for your help, I appreciate it.
  11. Hello Your explanation is good, But if lazy = ungreedy as possible, and .+ is 1 or more(lazy = 1), doesnt that mean .* being 0 or more (lazy = 0), that wouldnt be right either. So it seems the problem is the beginning and end delimiters? It now seems to work, Thanks ALOT for your help, I have been used alot of regex without ^ and $ as start/finish, I guess something like this was destined to happen.
  12. So therefore making .+ to .+? would make it lazy, but the result is still the exact same.
  13. Hello So im beginning to now apprach breaking point because of this regex, I cannot understand why such a simple thing will not work, my interpritation of making a subgroup optional is by adding a question mark ? to the end of it, Which would mean, If its there return sub match in the match, if its not there, dont worry. Whats actually happening is, if its there, its not returning the subgroup match in the whole match result, the same with if its not there. If the match exists, I want the sub group returned in the overall match, It is returning the whole match, but thats not included. Here is a simple example to see, I cant believe this isnt working, I have now spent over 5 hours trying every different combination, on such a simple thing, Its not long before I smash the place up <?php $string = 'I HAVE HAD ENOUGH OF THIS SHIT'; preg_match("/(I HAVE HAD ENOUGH).+(THIS SHIT)?/i",$string,$match); echo '<pre>'; var_dump($match); echo '</pre>'; ?>
  14. The solution I just done works like this $search = 'Rule Britanni'a King of : All'; $ignore[0] = array(',',':'); $ignore[1] = array(',?',':?'); $string = str_replace($ignore[0],$ignore[1],$string); preg_match("/$string/i",$search,$match); var_dump($match); This actually works fine, But wondered if there are other solutions quicker/better then what I have done
  15. Just a little update guys, I tested my above possible solution, and it worked, But I would appreciate some other alternatives as im sure there are some.
  16. Update. I just noticed one possible way this "may" be possible, havnt tested yet. What if I was to append a ? to each insensitive character in the string. This would tell regex to either find a , or : and match regardless. PS, If this does work, I would still like to hear your answer if you have alternatives, I believe there may be other ways to achieve this. Thanks all
  17. Cant seem to find any solution to this String 1 'Let's all go on holiday : America' String 2 'Lets all go on holiday America' When doing a match for this string, I class this as acceptable, However a straight regex will not accept this, Because of the full colon and comma. What I want to achieve, is exactly a case insensitive search, but with some characters to be insensitive about. To ignore case you just append i to the end of your pattern. I want to pay no attention to ' :, if its there ok, if its not and the rest matchs ok Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.