We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
random.word
1 parent a973ee1 commit 9702e32Copy full SHA for 9702e32
src/random.ts
@@ -199,11 +199,15 @@ export class Random {
199
'name.jobArea',
200
'name.jobType',
201
];
202
+ // regex statement used to remove unwanted characters from beginning/end of words
203
+ const wordSanitizerRegex = /^[\s()\[\]{}.,\-'"]+|[\s()\[\]{}.,\-'"]+$/g;
204
205
// randomly pick from the many faker methods that can generate words
206
const randomWordMethod = this.faker.random.arrayElement(wordMethods);
207
const result = this.faker.fake('{{' + randomWordMethod + '}}');
- return this.faker.random.arrayElement(result.split(' '));
208
+
209
+ // sanitize and return word
210
+ return this.faker.random.arrayElement(result.split(' ')).replace(wordSanitizerRegex, "");
211
}
212
213
readonly randomWord: Random['word'] = this.word.bind(this);
0 commit comments