How to remove all special characters from a string with magento 2 as a best practice?

Magento Contains Match.php file they contain CONSTANT like SPECIAL_CHARACTERS and with that constant all the special character are available.
File path is Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match.php

When we need to remove or replace special character with some other character you can use Magento default constant.

Match.php file with a constant declaration like as below,
const SPECIAL_CHARACTERS = ‘-+~/\\<>\'”:*$#@()!,.?`=%&^’;
When we need to modify a string with special character to some custom value or blank you can do as below way,

The result will be, Replace all special character with one space.
“Test1 23 45 789 1”

Magento 2 How to get child item id of configurable product by super attribute details?

Let’s assume you know configurable product id and used child product super attribute details.
Example from Magento Sample data configurable product name Chaz Kangeroo Hoodie,  Configurable product id is 67.
Super attribute Array details,

Using the bove details how we can get details of child item.

Refer below code snippet for Get child item id of a Configurable product by child’s Attribute details.

Call function,

Result is 52(Product name Chaz Kangeroo Hoodie-XS-Black). Using above way we got the child item data.

How to resolve Uncaught ReferenceError: jQuery is not defined(anonymous function) error magento 2?

Many time during custom development in Magento 2 using require js we have faced error like,

Uncaught ReferenceError: jQuery is not defined(anonymous function).
Uncaught TypeError: $(…).customjs is not a function.

Above issue can be resolved using require js paths and shim attribute of requirejs.
Most of the time issue occurs because of jQuery is not loaded before our custom js file due to AMD(asynchronously module dependencies) nature of require js.

Many of the custom js or Third party js library depends on Jquery to load first.
In Magento 2, Magento team used require js concept for improvement of site speed.

So you need to add dependencies in requirejs-config.js file as below. let’s assume you are using slider js names myslider.min.js and they depend on jquery. Your requirejs-config.js file will be as below,

Gives pathname under the paths object, Your myslider.min.js stay at app/code/<Vendor>/<Module>/view/frontend/web/js/myslider.min.js

Gives dependencies using shim attribute. Our slider depends on jquery.