How can I use regex to split on this `;` seperator? `Individual Portraits (5x7) (1); Individual Portrait (8x10) (1); Digital Download (Individual) (1)`
Asked on 2025-06-30
1 search
To split a string on the ;
separator using regex, you can use the following regular expression pattern in a programming language that supports regex, such as Python or JavaScript:
\s*;\s*
This pattern matches a semicolon (;
) surrounded by any amount of whitespace (including none). This ensures that any spaces around the semicolon are not included in the resulting split strings.
Here's an example of how you might use this in Python:
import re
text = "Individual Portraits (5x7) (1); Individual Portrait (8x10) (1); Digital Download (Individual) (1)"
result = re.split(r'\s*;\s*', text)
print(result)
This will output:
['Individual Portraits (5x7) (1)', 'Individual Portrait (8x10) (1)', 'Digital Download (Individual) (1)']
This approach ensures that the split operation is clean and does not include any leading or trailing spaces in the resulting list of strings.

Deep dive into the Foundation Models framework
Level up with the Foundation Models framework. Learn how guided generation works under the hood, and use guides, regexes, and generation schemas to get custom structured responses. We’ll show you how to use tool calling to let the model autonomously access external information and perform actions, for a personalized experience. To get the most out of this video, we recommend first watching “Meet the Foundation Models framework”.

Improve memory usage and performance with Swift
Discover ways to improve the performance and memory management of your Swift code. We’ll explore ways to refine your code – from making high-level algorithmic changes to adopting the new InlineArray and Span types for finer control over memory and allocations.

What’s new in Xcode
Discover the latest productivity and performance advancements in Xcode 26. Learn how to leverage large language models in your development workflow. Explore editing and debugging enhancements, improved performance and testing tools, and Swift Build - the open-source build system engine used by Xcode.