0

I am trying to get value from javascript with php preg_match, but not quite sure how can i do that .

I want "/cusa/includeFile.action?productOverviewCid=0901e024801e6aba&componentCid=0901e024800bef11&userSelectedModel=0901e024801e6aba" which come between "tabSpecifications" and , "Specifications"

here what i am trying to do, but not working.

$file = '
<script type="text/javascript">
            tabCls.push(
                new pageModelTab(
                "tabSpecifications"
                , "/cusa/includeFile.action?productOverviewCid=0901e024801e6aba&componentCid=0901e024800bef11&userSelectedModel=0901e024801e6aba"
                , "Specifications"
                , 3
                , false
                , ""
                , null
                , true
                , null
                )
                );
        function onClick_tabSpecifications() {
                try {
                var location = new String(window.location);
                if (location && location.indexOf("?selectedName") != -1) {
                return true;
                }
        new TabState("3").addTabToBrowserHistory();
                show("3");
                showHideFooterDisclaimer(\'Specifications\');
                return false;
                } catch (e) {
                //alert(e.message);
                return true;
                }
        }
            </script>';


preg_match("/^cusa/", $file );

i just start basics of preg_match ...

Please help

1 Answer 1

1

This worked for me -

$pattern = '/(\/cusa\/).*/';
preg_match($pattern, $file, $match);
print_r($match);

EXAMPLE

If you want to add to the search parameters (as asked in your comment) do this -

$pattern = '/(\/cusa\/includeFile.action).*/';
Sign up to request clarification or add additional context in comments.

1 Comment

Thx for help ... i was wondering can i find 'cusa/includeFile.action' value instead of cusa ... Please help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.