Jump to content

jodunno

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by jodunno

  1. so today i have tried multiple cominations and they have failed as you had predicted. I really don't want to ignore html code and seek only script. I really just wanted to verify letters plus optional wordbreak with soft hyphen. Rather than spend weeks trying to learn the correct regex statement, i have a better idea: i will check each name for wbr shy code, extract the code and set the extracted text to a temp variable, then apply html entities to the string, then reapply the wbr shy. a bit more work but better than rattling my brain for weeks trying to get the regex correct. Thank you for your time and patience.
  2. Hi requinix, i've cleaned the code now to exclude my mistakes. sorry. i really don't know alot about regex. I know one thing: you are very kind and helpful. Thank you! I really appreciate the interaction with you. i am mentally tired now and i really needed a coder to look at my expressions. I'm shutting the xampp down now. i go to bed soon. $checkname = 'NameMe'; //$checkname = 'Rückenseiten<wbr>&shy;tiere'; //$checkname = 'Name Me'; //$checkname = 'Name<script>alert(\'F**koff\')</script>Me'; if (!preg_match("/^\p{L}{2,32}<wbr>&shy;?\p{L}{2,16}?$/", $checkname)) { if (!preg_match("/^\p{L}{2,24}\s?\p{L}{2,24}?$/", $checkname)) { echo 'checkname === 0'; } else { echo 'checkname === 1'; } } else { echo 'checkname === 1'; } this time i have coded the f-word in the script test.
  3. oh, lord. I just realized that i didn't edit the script part of my code. I apologize! i cannot believe that i left it in the code. I hope that noone here is offended. I didn't mean to leave the 'f' word in my code example. i will edit it now. edit: the edit button disappeared. please will a moderator escape the 'f' word in my code? i sincerely apologize for this error.
  4. yes, i am an idiot about this subject. i don't really understand it yet. Thus, i did not know that lt and gt do not need to be escaped. I also did not know that the assertions are useless. why, may i ask? nevermind. i can read about that in spare time. it's not your business to educate me. my apologies for asking. anyway, i have alot of words that are broken where i want them to be broken - so not really 10 and 2. Plus, user supplied names could be broken wherever a user wishes. I just want to be sure that only lt wbr gt amp shy semicolon is allowed. Nothing else between words except a space whenever a wordbreak is not included. i will try to rewrite my code and to understand where i go wrong.
  5. Hi requinix and Thank you for taking time to reply, i understand your reply but i wonder why you think that my expression is invalid? it is working on my xampp with php, so i assume that the expression is valid according to regex rules. I say this because it is actually doing what i want it to do, albeit, i need a second check to see if it falls into the non html coded word: $checkname = 'Name Me'; //$checkname = 'NameMe'; //$checkname = 'Rückenseiten<wbr>&shy;tiere'; //$checkname = 'Name Me'; $checktrue4 = 'Name<script>alert(\'Fuckoff\')</script>Me'; if (!preg_match("/^(?:^)(\p{L}){2,24}(\<wbr\>\&shy\;)?(\p{L}){2,24}?(?:$)$/", $checkname)) { if (!preg_match("/^(?:^)(\p{L}){2,24}(\s)?(\p{L}){2,24}?(?:$)$/", $checkname)) { echo 'checkname === 0'; } else { echo 'checkname === 1'; } } else { echo 'checkname === 1'; } try my code and uncomment each variable to test it. i seem to have accomplished all of my goals without ignoring code. Is this really invalid?
  6. I forgot to mention that the icon names are not user supplied now but i'd like them to be editable in the future. so i'd like to work this code into my php code all ready. I actually spent 10 hours on this today. I can't even get it working until just before i posted here. I really wanted to allow utf-8 characters so umlauts of German can be included as well as French accents but this is too much for me, so az-AZ is good and an optional space before an optional second word or one word with a wordbreak soft hyphen only.
  7. Hi requinix, I have spent all day working on this problem. I could be doing alot of other things. I'm getting sick of this problem now. So, yes, i tried playing with regex until it did what i wanted it to do. I imagine a smart regex hacker, like you, can see a very simple solution. I can cnot see it. I have tried all day. I hope that i can explain the problem clear enough: i am using data as a hyperlink beneathe an icon. The data is not user supplied but i use wordbreaks with soft hyphens to break long words where i want them to break. I like to check my strings to verify that they are a-zA-Z only excluding the wordbreak. Thus my problems to solve are as follows: The entire strings must be no shorter than 3 letters and no longer than 48 letters including wordbreak code and a single space. (i've counted and the longest word yet is 36 characters). The string should be a-zA-Z only with one space allowed between two words. So two words are allowed following these rules. So 1 or 2 words with a space between 2 words. The string could be one word with a wordbreak and soft hyphen. Thus less than wbr greater than ampersand shy semicolon is allowed. RequinixIsAregexPro should pass as a-zA-Z less than 48 characters American Robin needs to pass as it is a-zA-Z and a single space between the two words. The German word Ruechenseitentiere is too long for me, so it should be allowed to pass as Ruckenseiten<wbr>&shy;tiere Nothing else should pass. Especially php, html and javascriptcode. Is it possible to simplify my hard-earned amateur expression? Thank you for taking time to read my post and reply. Meantime, i will keep trying to understand this problem and brush up on my regex knowledge. I am tired today now so i think that i will put this one away for now.
  8. I found a solution. Thanks anyway. ^(?:^)([a-zA-Z+]){2,26}(\<wbr\>\&shy\;)?([a-zA-Z+]){2,12}?(?:$)$ it works, i guess. The letters after the soft hyphen shouldn't be more than 8-10 letters anyway. i'll recalculate but it works. Now i wonder how to allow a single space between first word and last optional word?
  9. Hello forummembers, I am battling a regex expression. I got the expression to work but i can't figure out how to limit the string size - No matter where i place the curly braces {2,48}. my desire to use a regex is to filter my variables for matching formula. My formula is any word a-zA-Z with an optional string between that should only be a soft wordbreak in html code followed by optional letters a-zA-Z. so Mystringname should pass, Mystring<wbr>­name should pass but Mystring<script>alert(f**k off)</script> should fail. I got it working but i can't figure out how to limit the string length to 48 characters. Anyone able to help me? here is my working regex (maybe someone thinks of a better regex?) /^(?:^)([a-zA-Z]+)(\<wbr\>\&shy\;)?([a-zA-Z]+)?(?:$)$/ EDIT: I use php, so PCRE regex rules. Thank you.
×
×
  • 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.