vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Regex help (https://vborg.vbsupport.ru/showthread.php?t=193847)

Ziki 10-17-2008 12:22 PM

Regex help
 
Hello,

I am just learning some of the regular expressions and I would like to make a code to check if the specific field contains two words.It is to check if the user entered his first and last name not only his first name.Is there also a way to check if the two words are the same?And maybe combine these two so they can be added into the vb custom field regex?

Thank you very much!

Dismounted 10-18-2008 10:25 AM

<a href="http://www.regular-expressions.info/tutorial.html" target="_blank">http://www.regular-expressions.info/tutorial.html</a>

That is probably a good starting point to learn regex.

Ziki 10-19-2008 05:13 PM

Yes,but I am not very familiar with regex yet,and I was hoping for a specific code :)

Eikinskjaldi 10-20-2008 02:10 AM

If you are looking for specific words then regex is not necessary. You only need it when looking for patterns (like words containing "abc")

For exact string matches you should use the php exact string functions (of which there are a bunch, and any php documentation will have them).

To check if the field contains two words I would use explode and then check that the array contains two elements. Seeing if they are the same is just a matter of
if ($names[0] == $names[1])..... (though you might like to correct for case insensitivity)

Ziki 10-20-2008 10:34 AM

Oh yes,good idea :) thank you.


All times are GMT. The time now is 04:53 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00938 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete