Jump to content

jimmydorry

New Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jimmydorry's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks everyone for your contributions. I'm now up and running. Sorry, I didn't respond until now... I was preoccupied for the last two days. Thanks your expression does work in the proper environment, and so does the rest of your code. I was trying to test if the actual regex pattern you wrote worked (since I was at uni where I didn't have access to a proper dev environment)... and I can see from what you wrote why it failed now. And that is a very interesting way of doing it without the OFFSET_CAPTURE flag. Thanks for sharing.
  2. I understand what is meant now. I just need to formulate the REGEX now. I tried the pattern above on this site: http://www.pagecolumn.com/tool/pregtest.htm ... since I am not home right now. It did not work, but might do the job in a proper development environment. When I get home, I will try adapting the pattern I first proposed. The strings will all look like: '[HorribleSubs] Bleach – 311 [720p].mkv' '[NARUTO-BASE.RU] Bleach – 311 [720p]_[ENG].mkv' Some might have multiple hyphens, but most will be like the first one with 1 hyphen. The numbers might not occur directly after the hyphen, as there might be a space... an underscore... multiple characters...etc. I just need the first number that occurs after a hyphen... i.e. ignores the other hyphens and grabs the first number. It is likely that some strings might not have numbers. Is it possible to cater for that in the regex? Or can that only be done by checking the output in the php code?
  3. Oh, and your solution worked as intended.
  4. Could you give me an example? I don't see what you mean by PREG_OFFSET_CAPTURE. I should have written this was in php, but I assumed since I posted it here people would assume it was.
  5. Wow, it bloody works. Would you mind explaining what the '?' does, and how you knew to use it? Thanks a heap man. EDIT: From what I understand, it means that the phrase can occur 0 or 1 times. ? makes the .* "ungreedy", so it doesn't match the ( or [. Alternate way (untested): '%\][^\(\[]+[\(\[]%i' Not sure if you needed the capturing parentheses but I removed them. I understand your alternate solution better, and will have to try it later. Thanks for the explanations though, and for both solutions. If I understand correctly, the alternate solution utilises the regex operator of NOT EQUAL TO. Thus it is saying grab everything after ']' that is not '(' OR '['.
  6. Problem: I need to find the position of the first occuring integer after the first hypen. Help would be appreciated. Proposed Pattern: '%([\d]+)%' Test Strings: '[HorribleSubs] Bleach – 311 [720p].mkv' '[NARUTO-BASE.RU] Bleach – 311 [720p]_[ENG].mkv' Result: N/A (I have no idea how we can get the string position in this situation... I was thinking of extracting the integer with the above code, and then doing a strpos method to find where it starts... but that isn't very elegant. I was also not too sure on how to find the first number occuring after a hyphen. You may also notice that the second string has two hypens before the first number, so I will need to be able to handle that.) Expected Result: ~24 (I'm bad at counting )
  7. Wow, it bloody works. Would you mind explaining what the '?' does, and how you knew to use it? Thanks a heap man. EDIT: From what I understand, it means that the phrase can occur 0 or 1 times.
  8. I can't seem to get this OR statement working... it's the '|' character. expression: '%\](.*)(\(|\[)%mis' string: '[HnG] DD Hokuto no Ken 02 (TV) [8BC696B8].​avi' result: ' DD Hokuto no Ken 02 (TV) ' expected result: ' DD Hokuto no Ken 02 '
×
×
  • 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.