Title: REGEX Regular Expression
Last modified: August 21, 2016

---

# REGEX Regular Expression

 *  [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/)
 * I’m trying to figure out how i can use one or more regular expressions to format
   a random $ number with 6-7 digits..
    e.g.
 * $606782 -> $606 782
    $300000 -> $300 000 $1237339 -> $1 237 339

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Lucas Karpiuk](https://wordpress.org/support/users/karpstrucking/)
 * (@karpstrucking)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5110858)
 * Assuming you’re doing this in PHP, you could use `number_format()` or maybe even`
   money_format()`
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5111039)
 * Any chance in a bit/lot more help? I’m really bad at regex.
 *  [Lucas Karpiuk](https://wordpress.org/support/users/karpstrucking/)
 * (@karpstrucking)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5111040)
 * If you’re using PHP the functions I mentioned do not require regex knowledge.
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5111041)
 * I’m using a regex search and replace plugin, but if you have a another solution?
   I know nothing about php and regex unfortunately. 🙁
 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5111042)
 * If you really want a regex solution, and you only want to change numbers with
   6 or 7 digits, try something like:
 *     ```
       $string = preg_replace(array('(\d\d\d)(\d\d\d)','(\d)(\d\d\d)(\d\d\d)'), array('$1 $2','$1 $2 $3'), $string);
       ```
   
 * If you can remove the money ($) character, **number_format** is a much better
   solution since it will work with any size number.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘REGEX Regular Expression’ is closed to new replies.

## Tags

 * [regex](https://wordpress.org/support/topic-tag/regex/)
 * [regular expression](https://wordpress.org/support/topic-tag/regular-expression/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 5 replies
 * 3 participants
 * Last reply from: [Dion](https://wordpress.org/support/users/diondesigns/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/regex-regular-expression/#post-5111042)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
