Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2010, 12:50 PM
Koidl Koidl is offline
 
Join Date: Apr 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default regex advise plz

i am not sure if i use the preg right can someone give me advise i cant use it like that in the profile fields

PHP Code:
enteredText value entered by the user in the field

IF regexCheck("^\d{8,10}$"enteredTextTHEN
    finalURL 
"http:/domain.com/" enteredText "/"
ELSE
    
send error message to user that the value must be between 8 and 10 digits only
END 
IF 

thanks
Reply With Quote
  #2  
Old 06-03-2010, 01:22 PM
Speysider's Avatar
Speysider Speysider is offline
 
Join Date: Apr 2009
Posts: 1,029
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You shouldn't use capital PHP code like IF, ELSE, END IF etc
You'd use something like:
Code:
if (whatever condition you want here)
  {
  result if condition is true
  }
else
  {
  result if the condition is not true
  }
Replacing the part between brackets with whatever you want to happen.
Reply With Quote
  #3  
Old 06-03-2010, 02:02 PM
Koidl Koidl is offline
 
Join Date: Apr 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Speysider View Post
You shouldn't use capital PHP code like IF, ELSE, END IF etc
You'd use something like:
Code:
if (whatever condition you want here)
  {
  result if condition is true
  }
else
  {
  result if the condition is not true
  }
Replacing the part between brackets with whatever you want to happen.
i tryed it like that now but still not working

HTML Code:
if ("^\d{8,10}$", enteredText)
  {
  finalURL = "http:/domain.com/" + enteredText + "/"
  }
else
  {
  value must be between 8 and 10 digits only
  }
Reply With Quote
  #4  
Old 06-03-2010, 02:15 PM
Speysider's Avatar
Speysider Speysider is offline
 
Join Date: Apr 2009
Posts: 1,029
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is your regex correct??
Reply With Quote
  #5  
Old 06-03-2010, 02:39 PM
Koidl Koidl is offline
 
Join Date: Apr 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Speysider View Post
Is your regex correct??
yes the regex alone works
Reply With Quote
  #6  
Old 06-04-2010, 11:47 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use:
PHP Code:
if (preg_match("REGEX"$string))
{
}
.... 
See the php manual: http://th2.php.net/manual/en/function.preg-match.php
Reply With Quote
  #7  
Old 06-04-2010, 12:16 PM
Koidl Koidl is offline
 
Join Date: Apr 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
You can use:
PHP Code:
if (preg_match("REGEX"$string))
{
}
.... 
See the php manual: http://th2.php.net/manual/en/function.preg-match.php
i tryed already alot after reading all this examples
but i cant get it working

PHP Code:
if (preg_match("^d{8,10}$"$string))
  {
  echo 
"http:/domain.com/" $string "/";
  }
else
  {
  echo 
"value must be between 8 and 10 digits only";
  } 
PHP Code:
if (preg_match("^d{8,10}$"$string))
  {
  
print_r("http:/domain.com/" $string "/");
  }
else
  {
  echo 
"value must be between 8 and 10 digits only";
  } 
Reply With Quote
  #8  
Old 06-04-2010, 12:32 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And what is not working and where do you place this?
Reply With Quote
  #9  
Old 06-04-2010, 12:41 PM
Koidl Koidl is offline
 
Join Date: Apr 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i placed it in a costumer profile field under "Regular Expression"
the regex is working but it dont transforms it in a link also the error message for wrong valve is not working
Reply With Quote
  #10  
Old 06-04-2010, 01:02 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In a custom profile field you can only place an expression that results in true (1) or false (0). You can not perform actions like showing a text.

See the admin help for this field by clicking on the question mark at the right of the field.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:42 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09425 seconds
  • Memory Usage 2,257KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete